View Full Version : How to open QMainWindow object from QDialog object as an active window
sanjeet
15th July 2011, 10:20
I want to open QMainWindow Object in QDialog Object as an active window or top level window.
My code is like this :
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.
Santosh Reddy
15th July 2011, 10:28
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
sanjeet
15th July 2011, 18:00
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.
Santosh Reddy
15th July 2011, 18:18
I guess you are creating a modal dialog, try this
void MyDialog:penMyForm()
{
setModal(false);
myForm = new QMainWindow;
myForm->show();
}
Update: You can also make dialog as parent of QMainWindow, this way mainwindow till remain on top of dialog
void MyDialog:penMyForm()
{
setModal(false);
myForm = new QMainWindow(this);
myForm->show();
}
viulskiez
15th July 2011, 18:31
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);
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.