Problems with QDialog in Qt

Posted by Martin on Stack Overflow See other posts from Stack Overflow or by Martin
Published on 2010-04-20T08:28:18Z Indexed on 2010/04/20 8:33 UTC
Read the original article Hit count: 474

Filed under:
|

I'm using Qt for Symbian. I have some problems with a QDialog that I open from a QMenu. The QDialog shows up fine and in the QDialog I have a QDialogButtonBox with a button to Close the QDialog. BUT if I close the QDialog and then open it from the QMenu again, it will show up but the button from the QDialogButtonBox will not show up. Instead the buttons from the QMainWindow will show but they are grayed out.

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

It's not much code that I use, you can try it yourself. This is my code:

In QMainWindow I use 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 shows the QDialog:

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

This is the TestDialog:

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

© Stack Overflow or respective owner

Related posts about qdialog

Related posts about qt