Important: Please read the Qt Code of Conduct -

How dont close the dialog window if Ok in ButtonBox is clicked but some condition is not true

  • If the WidgetCell will empty when I press OK it closes, but I would like it doesn't close, hope your ideas help me to resolve the problem, thanks.
    0_1510418406469_Capture10.PNG my code

  • Hi,

    You need to control in real time your QLineEdits (with textEdited() signal I presume)
    checking the validity of them in the slot method and enabled the OK button accordingly:

    QPushButton * okBut=ui->buttonBox->button(QDialogButtonBox::Ok);
    if(valid) // all the fields are valid

    You problably also need to set the OK button to false (disabled) when the dialog show up.

  • @mpergand thanks,Yes you are right I do it in a such way
    connect(line, SIGNAL(textChanged(const QString &)), this, SLOT(DBsearching(const QString &)));
    void Dialog::DBsearching(const QString & s)
    for(int row = 0; row<ui->tableWidget->rowCount();row++)
    QLineEdit l = ui->tableWidget->cellWidget(row,2)->findChild<QLineEdit>();

  • So, is your issue/question resolved or not? If so please mark the post as solved.

  • @kenchan The question is resolved (what to click to mark as resolved could you help)

  • There should be a menu item to set the post as resolved in the "Topic Tools" menu drop down on the right of the reply and other buttons.
    Usually under your original post.

Log in to reply