
Originally Posted by
Lesiok
Show the code snippet where you create a new window. I think the problem is that using show() instead of exec().
You're right.
I have a QDialog. I tried to change it to exec(), and it worked!
But with QWidgets this does not work ...
//constructor MainWindow
settings = new COMSettings; //QDialog
passform = new PasswordForm(); //QWidget
initActionConnection();
//...//
void MainWindow::manualModeAction()
{
if (manualModeState)
{
reply.setStyleSheet("QLabel{min-width:500 px; min-height:150 px} QPushButton{ width:250px; min-height:50 px}");
reply.setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint);
reply.setText("<p align='center'>Exit?</p>");
manualMode(false);
}
else
{
passform->show();
}
}
void MainWindow::initActionConnection()
{
connect(ui->manualModeButton, SIGNAL(clicked()), this, SLOT(manualModeAction()));
connect(ui->comSetButton, SIGNAL(clicked()), settings, SLOT(exec()));
}
//constructor MainWindow
settings = new COMSettings; //QDialog
passform = new PasswordForm(); //QWidget
initActionConnection();
//...//
void MainWindow::manualModeAction()
{
if (manualModeState)
{
QMessageBox reply;
reply.setStyleSheet("QLabel{min-width:500 px; min-height:150 px} QPushButton{ width:250px; min-height:50 px}");
reply.setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint);
reply.setText("<p align='center'>Exit?</p>");
reply.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
if (reply.exec() == QMessageBox::Yes)
manualMode(false);
}
else
{
passform->show();
}
}
void MainWindow::initActionConnection()
{
connect(ui->manualModeButton, SIGNAL(clicked()), this, SLOT(manualModeAction()));
connect(ui->comSetButton, SIGNAL(clicked()), settings, SLOT(exec()));
}
To copy to clipboard, switch view to plain text mode
Bookmarks