Problems with QDialog in Qt

I am using Qt for Symbian. I have some problems with QDialog which I open from QMenu. The QDialog displays well and in the QDialog I have a QDialogButtonBox with a Close QDialog button. BUT if I close the QDialog and then reopen it from the QMenu it appears, but the button from the QDialogButtonBox does not appear. Instead, the buttons from the QMainWindow will show, but they are grayed out.

How can I show QDialog buttons every time? Maybe I have some problems setting focus on QDialog? I really can't see what I am doing wrong here.

Not much code I'm using, you can try it yourself. This is my code:

The QMainWindow uses the following to create the menu:

QAction *menuButton = new QAction("Menu", this);
menuButton->setSoftKeyRole(QAction::PositiveSoftKey);

QMenu *menu = new QMenu(this);
menuButton->setMenu(menu);

QAction *popup = new QAction("Show popup",this);
connect(popup, SIGNAL(triggered()), this, SLOT(showPopup()));
menu->addAction(popup);

addAction(menuButton);

      

This is what the QDialog shows:

void MyMainWindow::showPopup(){
TestDialog *test = new TestDialog(this);
test->setAttribute(Qt::WA_DeleteOnClose);
test->show();
}

      

This is TestDialog:

TestDialog::TestDialog(QWidget *parent)
: QDialog(parent)
{
ui.setupUi(this);
QDesktopWidget* desktopWidget = QApplication::desktop();
QRect rect = desktopWidget->availableGeometry();
this->setFixedWidth(rect.width());
}

      

+2


a source to share


1 answer


If you want your dialog to be modal then use exec (). Otherwise, you must use show () and raise () to do it from above.



0


a source







All Articles