Important: Please read the Qt Code of Conduct -

Problem with QMessagebox with IOS.. Application becomes unresponsive

  • I have a simple implementation of a QMessagebox in the application which otherwise runs well on IOS.
    However, when I have a QMessagebox as shown here, after the dialog pop up, the application becomes unresponsive.
    This messagebox is being called from an action on the toolbar.

        QMessageBox msg;
        msg.setText(tr("Do you really want to delete the block?"));
        msg.setWindowFlags(Qt::WindowStaysOnTopHint | Qt::Dialog);
        int ret = msg.exec();

    I though the problem might be related to this bug.

    However I dont know any solution.

    I was trying to see if I can use a uialertcontroller objective C example, but i did not get the right way to do it.

    I would appreciate help to solve this problem.


  • Lifetime Qt Champion

    What Qt version are you using ?
    Also did you try Qt::QueuedConnection as mentioned.

  • @mrjj I am using Qt 5.10.1 on IOS.
    I could not understand how to implement the Qt::QueuedConnection in this case.
    I have an action which is connected to the slot auto generated by QtCreator.
    In that slot I have some code and one part of that is getting the feedback from the user regarding whether to delete the block selected or not. If Yes, then the block is selected.
    Do I need to add another connect statement linking the trigger of that action to the slot as Qt::QueuedConnection?

  • @mrjj connect(ui->actionErase_Block,&QAction::triggered,this,&RapidMainDesigner::on_actionErase_Block_triggered_1,Qt::QueuedConnection);

    I tried to override the slot connection done by default and tried to implement the connect with a QueuedConnection. However, the problem still persists.

    Any other way to do this QueuedConnection?

  • @mrjj My IOS version is 11.4.1

  • Lifetime Qt Champion

    Well adding a new connection will not override the old one.
    You could use disconnect.

    However, i was more thinking of
    manually adding a new action from code and be using QueuedConnection to test
    if that actually works then.
    I read the link as he manually connected the actions and then it worked.

  • @mrjj manually adding a new action and using QueuedConnection to test also did not work.

  • Lifetime Qt Champion

    Ok. it sounded like the others got it working that way. but maybe not in all cases.
    It sounds like its fixed in 5.9.4
    What Qt are you on ?

  • @mrjj I am using Qt5.10.1

  • @mrjj I dont see a solution to this problem. I was trying to solve it by creating a custom dialog box with buttons for asking user input.
    Ideally, i should have a window that is translucent and a opaque frame with buttons and a label.
    Do you think this will be feasible?

  • Lifetime Qt Champion

    Would it be possible to test with 5.9.4 ?

    Well the issues seems to be related to exec()
    so a new dialog might not work better than QMessageBox
    however , its worth a shot.

  • @mrjj if I execute the dialog with exec in a static function, that seems to work.

    Invoking the dialog this way works.

        int ret = iosmsgbox::showmessagebox(tr("Do you really want to delete the block?"),QString(),tr("Yes"),tr("No"));

    The dialog header...

    #ifndef IOSMSGBOX_H
    #define IOSMSGBOX_H
    #include <QDialog>
    namespace Ui {
    class iosmsgbox;
    class iosmsgbox : public QDialog
        explicit iosmsgbox(const QString &message,const QString &btn1txt,const QString &btn2txt,const QString &btn3txt,QWidget *parent = 0);
        static int showmessagebox(const QString &message,const QString &btn1txt,const QString &btn2txt,const QString &btn3txt,QWidget *parent = 0);
    private slots:
        void on_btn_1_clicked();
        void on_btn_2_clicked();
        void on_btn_3_clicked();
        Ui::iosmsgbox *ui;
        int selvalue;
    #endif // IOSMSGBOX_H

    The dialog cpp.

    #include "iosmsgbox.h"
    #include "ui_iosmsgbox.h"
    iosmsgbox::iosmsgbox(const QString &message,const QString &btn1txt,const QString &btn2txt,const QString &btn3txt,QWidget *parent) :
        ui(new Ui::iosmsgbox)
        delete ui;
    int iosmsgbox::showmessagebox(const QString &message, const QString &btn1txt, const QString &btn2txt, const QString &btn3txt, QWidget *parent)
        int returnvalue;
        iosmsgbox *mymsg = new iosmsgbox(message,btn1txt,btn2txt,btn3txt,parent);
        delete mymsg;
        return returnvalue;
    void iosmsgbox::on_btn_1_clicked()
    void iosmsgbox::on_btn_2_clicked()
    void iosmsgbox::on_btn_3_clicked()

    Now I am confused on how to make the background translucent and make just the buttons housed in the frame visible properly.

  • Lifetime Qt Champion

    Ok, so its not directly related to exec().
    Good test then.
    One note. i dont think you have to new it. since exec is blocking.
    iosmsgbox mymsg(message,btn1txt,btn2txt,btn3txt,parent);

    should work just as well.

    • background translucent

    Is the normal messagebox translucent ? or why you want this ?

    • buttons housed in the frame visible properly.
      You mean dialog is too small or why are they not ok ?

  • @mrjj
    The Transluscent background and visible frame is only about trying to give the look similar to the messagebox.
    But this workaround works for me.

Log in to reply