You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Wednesday, April 13th 2005, 12:53pm

messagebox comes bihind parent window

i have two forms like form A & B.
when program runs form A comes & then form A has a pushbutton through which i call form B.when i get form B then i click pushbutton (form B has this pushbutton this pushbutton is the member of form B's class ) this pushbutton calls messagebox::info which comes behind of form B

what i do now
regards
rani krishna

zlatko

Professional

  • "zlatko" is male

Posts: 728

Location: Ukraine,Lviv

Occupation: programmer

  • Send private message

2

Wednesday, April 13th 2005, 12:59pm

what parent you give to your messagebox?
a life without programming its alike empty bottle 8)

3

Wednesday, April 13th 2005, 1:01pm

RE: messagebox comes bihind parent window

Strange behaviour...
Are you using the static qmessagebox::information syntax to create a modal dialog to the window B?
It shouldn't be possible to appear behind its parent... it modal!
By the way: what parent do you assign to the messagebox widget? A? B? NULL? Something else?
There's no place like ::1

MarkoSan

Intermediate

  • "MarkoSan" is male

Posts: 230

Location: Ljubljana, SI-EU

Occupation: Embedded Systems Engineer I

  • Send private message

4

Wednesday, April 13th 2005, 1:04pm

i have similiar problem, if i launch i qdialog from menu, it is shown, but in windows taskbar as separate application, but i want to be this qdialog under main windows, which includes menu.
there is no home like 127.0.0.1 ;)
MS Winidows XP SP2; MS Visual Studio 2005 SP1 with that regresion patch; Qt 4.2.1 Commercial

MarkoSan

Intermediate

  • "MarkoSan" is male

Posts: 230

Location: Ljubljana, SI-EU

Occupation: Embedded Systems Engineer I

  • Send private message

5

Wednesday, April 13th 2005, 1:05pm

in both cases i think it is parent paramater, that is not ok. I give this as paramater of parent window. Is this ok? And how do i get pointer to parent window, is there any method?
there is no home like 127.0.0.1 ;)
MS Winidows XP SP2; MS Visual Studio 2005 SP1 with that regresion patch; Qt 4.2.1 Commercial

myfairlady

Beginner

  • "myfairlady" is female

Posts: 35

Occupation: Software Engineer

  • Send private message

6

Wednesday, April 13th 2005, 1:27pm

ya thats right ..... its the parent parameter problem ...... give the parent as "this" if ur starting the qdialog from ur main window or write ur own method to get the parent .......
I think krishna u must also have done the same mistake of giving the worng parent ....... make form B as parent

MarkoSan

Intermediate

  • "MarkoSan" is male

Posts: 230

Location: Ljubljana, SI-EU

Occupation: Embedded Systems Engineer I

  • Send private message

7

Wednesday, April 13th 2005, 1:36pm

yes, i did that, but result is the same!!!! Here is a code:

void QBlaMainWindow::slotShowBwArtikli()
{
m_pSifrantArtiklovWindow=new QBlaSifrantArtiklovWindow();
Q_CHECK_PTR(m_pSifrantArtiklovWindow);
m_pSifrantArtiklovWindow->setCaption("Šifrant artiklov");
m_pSifrantArtiklovWindow->resize(800, 600);
m_pSifrantArtiklovWindow->setModal(TRUE);
m_pSifrantArtiklovWindow->show();

//m_pSifrantArtiklovWindow->exec();
}

QBlaMainWindow is derived from QMainWindow and slotShowBwArtikli is slot, which is triggered from main menu (menu, which resides in QMainWindow) and show QDialog . What is wrong in here?
there is no home like 127.0.0.1 ;)
MS Winidows XP SP2; MS Visual Studio 2005 SP1 with that regresion patch; Qt 4.2.1 Commercial

myfairlady

Beginner

  • "myfairlady" is female

Posts: 35

Occupation: Software Engineer

  • Send private message

8

Wednesday, April 13th 2005, 1:50pm

QBlaSifrantArtiklovWindow() ..... where is this class derived from ??? is is derived from ur main window ????
Pass the instance of the main window to the constructor of the class which u want to display as dialog

9

Wednesday, April 13th 2005, 1:50pm

Any class inheriting QWidget (e.g. QMainWindow) can be put to front using the raise() method...
But this is not applicable with the static QMessageBox as you don't have a pointer to the object itself...
There's no place like ::1

MarkoSan

Intermediate

  • "MarkoSan" is male

Posts: 230

Location: Ljubljana, SI-EU

Occupation: Embedded Systems Engineer I

  • Send private message

10

Wednesday, April 13th 2005, 1:51pm

QBlaSifrantWindow is derived from QDialog
there is no home like 127.0.0.1 ;)
MS Winidows XP SP2; MS Visual Studio 2005 SP1 with that regresion patch; Qt 4.2.1 Commercial

myfairlady

Beginner

  • "myfairlady" is female

Posts: 35

Occupation: Software Engineer

  • Send private message

11

Wednesday, April 13th 2005, 2:22pm

u can do somthing like this ..... use the folowwing line when initializing ur "m_pSifrantArtiklovWindow" instead of what u have written

m_pSifrantArtiklovWindow=new QBlaSifrantArtiklovWindow(this, 0, true, 0);

reduce the resizing parameters a little ....... u will have the dialog in the same main window that is ur paarent .....

Make sure that the class that u have derived from QDialog has the proper constructor which takes the widget, flags etc ......

MarkoSan

Intermediate

  • "MarkoSan" is male

Posts: 230

Location: Ljubljana, SI-EU

Occupation: Embedded Systems Engineer I

  • Send private message

12

Wednesday, April 13th 2005, 4:27pm

what do these parameters mean:

(this, 0, true, 0);

so i can remake constructor.
there is no home like 127.0.0.1 ;)
MS Winidows XP SP2; MS Visual Studio 2005 SP1 with that regresion patch; Qt 4.2.1 Commercial

MarkoSan

Intermediate

  • "MarkoSan" is male

Posts: 230

Location: Ljubljana, SI-EU

Occupation: Embedded Systems Engineer I

  • Send private message

13

Wednesday, April 13th 2005, 4:28pm

and my class looks like this:

class QBlaMainWindow : public QMainWindow
{
Q_OBJECT // to use signals and slots, this expression has to be added
public:
QBlaMainWindow();
~QBlaMainWindow();

// menu subclassing
private:
QMenuBar* m_pMainWindowMenu; // main menu
QPopupMenu* m_pMenuSifrant; // sifrant menu
QAction* m_pMainMenuShowSifrantWindowAction; // main menu action
// end of menu subclassing

// windows subclassing
private:
QBlaSifrantArtiklovWindow* m_pSifrantArtiklovWindow;
// end of windows subclassing

public slots:
void slotShowBwArtikli(void);
};
there is no home like 127.0.0.1 ;)
MS Winidows XP SP2; MS Visual Studio 2005 SP1 with that regresion patch; Qt 4.2.1 Commercial

MarkoSan

Intermediate

  • "MarkoSan" is male

Posts: 230

Location: Ljubljana, SI-EU

Occupation: Embedded Systems Engineer I

  • Send private message

14

Wednesday, April 13th 2005, 4:29pm

UPS ERROR, WRONG CLASS WAS PASTED, here is right class:

//class QBlaSifrantArtiklovWindow : public QWidget
class QBlaSifrantArtiklovWindow : public QDialog
{
Q_OBJECT // to use signals and slots, this expression has to be added
public:
QBlaSifrantArtiklovWindow();
~QBlaSifrantArtiklovWindow();

protected:
// windows
// TODO: delete all this windows, since dbms managment will be performed directly
// in browser windows, not in additional forms
QDialog* m_pSifrantArtiklovInsertWindow;
QDialog* m_pSifrantArtikliUpdateWindow;

protected:
// buttons on window
QPushButton* m_pButtonAdd;
QPushButton* m_pButtonChange;
QPushButton* m_pButtonDelete;
QPushButton* m_pButtonClose;

protected:
// horiz/vert alignment class
QHBoxLayout* m_pButtonHorizLayout;

protected:
// accelerators
QAccel* m_pButtonAddAccel;
QAccel* m_pButtonChangeAccel;
QAccel* m_pButtonDeleteAccel;
QAccel* m_pButtonCloseAccel;

protected:
// database related
QSqlDatabase* m_pSifrantArtiklovDataBase;
QDataTable* m_pSifrantArtiklovDataTable;
QSqlCursor* m_pSifrnatArtiklovCursor;

protected:
// keyboard handler
void keyPressEvent(QKeyEvent* e);

/*
public slots:
// object slots
// TODO: delete all this slots, since dbms managment will be performed directly
// in browser windows, not in additional forms
void slotShowInsertWindow();
void slotShowUpdateWindow();
void slotDeleteCurrentRecord();
*/

private slots:
// database managment slots
void slotAddRecord();
void slotUpdateRecord();
void slotDeleteRecord();
};
there is no home like 127.0.0.1 ;)
MS Winidows XP SP2; MS Visual Studio 2005 SP1 with that regresion patch; Qt 4.2.1 Commercial

MarkoSan

Intermediate

  • "MarkoSan" is male

Posts: 230

Location: Ljubljana, SI-EU

Occupation: Embedded Systems Engineer I

  • Send private message

15

Thursday, April 14th 2005, 5:38am

I've solved it god damn:

I CONNECTED WRONG KEY, I CONNECTED Qt:Enter instead of Qt: Return !!!! X( :D ?(:rolleyes:
there is no home like 127.0.0.1 ;)
MS Winidows XP SP2; MS Visual Studio 2005 SP1 with that regresion patch; Qt 4.2.1 Commercial

MarkoSan

Intermediate

  • "MarkoSan" is male

Posts: 230

Location: Ljubljana, SI-EU

Occupation: Embedded Systems Engineer I

  • Send private message

16

Thursday, April 14th 2005, 5:45am

sorry, that was replies to wrong thread!!! ignore it
there is no home like 127.0.0.1 ;)
MS Winidows XP SP2; MS Visual Studio 2005 SP1 with that regresion patch; Qt 4.2.1 Commercial

17

Thursday, April 14th 2005, 6:45am

RE: messagebox comes bihind parent window

this class is mail window A
class CMSS_Proto : public QMainWindow
{
Q_OBJECT


public :
CMSS_Proto( QWidget * parent = 0, const char * name = 0, WFlags f = WType_TopLevel );
};

class of form B is

class Form2 : public QDialog
{
Q_OBJECT

public:
Form2( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
~Form2();

QPushButton* AddUsrPushBut;

public slots:
virtual void tt2(); //thsi function contains pushbutton QMessageBox::information(this,"some text","some text",0)

protected:

protected slots:
virtual void languageChange();

};

void tt2()
{
QMessageBox::information(this,"some text","some text",0);
}

when program runs then form A come & through pushbutton of A form B comes
when i click pushbutton of B then messagebox comes bihind B and front of A
please help me

MarkoSan

Intermediate

  • "MarkoSan" is male

Posts: 230

Location: Ljubljana, SI-EU

Occupation: Embedded Systems Engineer I

  • Send private message

18

Thursday, April 14th 2005, 6:54am

Give us an implementation and I'll see what I can do
there is no home like 127.0.0.1 ;)
MS Winidows XP SP2; MS Visual Studio 2005 SP1 with that regresion patch; Qt 4.2.1 Commercial

19

Thursday, April 14th 2005, 7:20am

//this class is mail window A
class CMSS_Proto : public QMainWindow
{
Q_OBJECT
public :
CMSS_Proto( QWidget * parent = 0, const char * name = 0, WFlags f = WType_TopLevel );
};

//class of form B is

class Form2 : public QDialog
{
Q_OBJECT

public:
Form2( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
~Form2();

QPushButton* AddUsrPushBut;
public slots:
virtual void tt2(); //thsi function contains pushbutton //QMessageBox::information(this,"some text","some text",0)
protected:
protected slots:
virtual void languageChange();
};

void tt2()
{
Form2 *test = new Form2(this,0,true,0);
QMessageBox::information(this,"some text","some text",0);
}
i did as too.
when program runs then main window A comes & through pushbutton of A form B comes
when i click pushbutton of B then messagebox comes bihind B and front of A
please help me

MarkoSan

Intermediate

  • "MarkoSan" is male

Posts: 230

Location: Ljubljana, SI-EU

Occupation: Embedded Systems Engineer I

  • Send private message

20

Thursday, April 14th 2005, 7:32am

I think that you pass wrong parent to message box. Instead of form B, you pass to message form A as a parent of this message box and there fore is shown on form A and behind form B. But now is the problem how to cure this. Ok:

this class is mail window A
class CMSS_Proto : public QMainWindow
{
Q_OBJECT


public :
CMSS_Proto( QWidget * parent = 0, const char * name = 0, WFlags f = WType_TopLevel );
};

whare is you button, which triggers form B???
there is no home like 127.0.0.1 ;)
MS Winidows XP SP2; MS Visual Studio 2005 SP1 with that regresion patch; Qt 4.2.1 Commercial