How to open QMainWindow object from QDialog object as an active window
I want to open QMainWindow Object in QDialog Object as an active window or top level window.
My code is like this :
Quote:
connect ((open button on QDialog object)), SIGNAL (clicked()),this , SLOT (openMyForm()));
void MyDialog::openMyForm()
{
myForm = new QMainWindow;
myForm->show();
}
I have even used setActivateWindow() and raise() function call in openMyForm slot but still it's not working.
Re: How to open QMainWindow object from QDialog object as an active window
check these,
1. Check if the slot is being called
2. If slot is being called, then it should create a new QMainWindow, check if it not hidden below the QDialog
Re: How to open QMainWindow object from QDialog object as an active window
Hi Santosh,
First of all, thanks for replying.
I have already checked it...
1. Slot is called and
2. A new QMainWindow is created below the QDialog.
But my problem is i want to put this new QMainWindow above the QDialog,(not hidden below the QDialog) when it is created.
so can you help me.
Re: How to open QMainWindow object from QDialog object as an active window
I guess you are creating a modal dialog, try this
Code:
void MyDialog:penMyForm()
{
setModal(false);
myForm->show();
}
Update: You can also make dialog as parent of QMainWindow, this way mainwindow till remain on top of dialog
Code:
void MyDialog:penMyForm()
{
setModal(false);
myForm->show();
}
Re: How to open QMainWindow object from QDialog object as an active window
Do you show the dialog by calling QDialog::exec()? Use QDialog::show() instead of calling QDialog::exec(). If you want the main window always on top, you can set it as modal (setWindowModality(Qt::WindowModality);