Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Problem with QMessagebox with IOS.. Application becomes unresponsive
Forum Updated to NodeBB v4.3 + New Features

Problem with QMessagebox with IOS.. Application becomes unresponsive

Scheduled Pinned Locked Moved Solved Mobile and Embedded
14 Posts 2 Posters 1.8k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TheCrowKaka
    wrote on last edited by
    #1

    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.setStandardButtons(QMessageBox::Yes|QMessageBox::No);
        msg.setDefaultButton(QMessageBox::No);
        msg.setParent(this);
        msg.setWindowFlags(Qt::WindowStaysOnTopHint | Qt::Dialog);
        msg.setIcon(QMessageBox::Question);
        int ret = msg.exec();
        if(ret==QMessageBox::No)
            return;
    
    

    I though the problem might be related to this bug.
    https://bugreports.qt.io/browse/QTBUG-64577?page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel&showAll=true

    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.

    Thanks.

    A Qt Enthusiastic...

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

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

      T 2 Replies Last reply
      0
      • T Offline
        T Offline
        TheCrowKaka
        wrote on last edited by
        #3

        @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?

        A Qt Enthusiastic...

        1 Reply Last reply
        0
        • mrjjM mrjj

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

          T Offline
          T Offline
          TheCrowKaka
          wrote on last edited by
          #4

          @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?

          A Qt Enthusiastic...

          mrjjM 1 Reply Last reply
          0
          • mrjjM mrjj

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

            T Offline
            T Offline
            TheCrowKaka
            wrote on last edited by
            #5

            @mrjj My IOS version is 11.4.1

            A Qt Enthusiastic...

            1 Reply Last reply
            0
            • T TheCrowKaka

              @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?

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @TheCrowKaka
              HI
              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.

              T 1 Reply Last reply
              0
              • mrjjM mrjj

                @TheCrowKaka
                HI
                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.

                T Offline
                T Offline
                TheCrowKaka
                wrote on last edited by
                #7

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

                A Qt Enthusiastic...

                mrjjM 1 Reply Last reply
                0
                • T TheCrowKaka

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

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @TheCrowKaka
                  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 ?

                  T 2 Replies Last reply
                  0
                  • mrjjM mrjj

                    @TheCrowKaka
                    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 ?

                    T Offline
                    T Offline
                    TheCrowKaka
                    wrote on last edited by
                    #9

                    @mrjj I am using Qt5.10.1

                    A Qt Enthusiastic...

                    1 Reply Last reply
                    0
                    • mrjjM mrjj

                      @TheCrowKaka
                      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 ?

                      T Offline
                      T Offline
                      TheCrowKaka
                      wrote on last edited by
                      #10

                      @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?

                      A Qt Enthusiastic...

                      mrjjM 1 Reply Last reply
                      0
                      • T TheCrowKaka

                        @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?

                        mrjjM Offline
                        mrjjM Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        @TheCrowKaka
                        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.

                        T 1 Reply Last reply
                        0
                        • mrjjM mrjj

                          @TheCrowKaka
                          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.

                          T Offline
                          T Offline
                          TheCrowKaka
                          wrote on last edited by
                          #12

                          @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
                          {
                              Q_OBJECT
                          
                          public:
                              explicit iosmsgbox(const QString &message,const QString &btn1txt,const QString &btn2txt,const QString &btn3txt,QWidget *parent = 0);
                              ~iosmsgbox();
                              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();
                          
                          private:
                              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) :
                              QDialog(parent),
                              ui(new Ui::iosmsgbox)
                          {
                              ui->setupUi(this);
                              
                              selvalue=0;
                              ui->btn_1->setVisible(!btn1txt.isEmpty());
                              ui->btn_1->setText(btn1txt);
                              ui->btn_2->setVisible(!btn2txt.isEmpty());
                              ui->btn_2->setText(btn2txt);
                              ui->btn_3->setVisible(!btn3txt.isEmpty());
                              ui->btn_3->setText(btn3txt);
                          }
                          
                          iosmsgbox::~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);
                              mymsg->exec();
                              returnvalue=mymsg->selvalue;
                              mymsg->close();
                              delete mymsg;
                              return returnvalue;
                          }
                          
                          void iosmsgbox::on_btn_1_clicked()
                          {
                              selvalue=1;
                              this->hide();
                          }
                          
                          void iosmsgbox::on_btn_2_clicked()
                          {
                              selvalue=2;
                              this->hide();
                          }
                          
                          void iosmsgbox::on_btn_3_clicked()
                          {
                              selvalue=3;
                              this->hide();
                          }
                          
                          

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

                          A Qt Enthusiastic...

                          mrjjM 1 Reply Last reply
                          0
                          • T TheCrowKaka

                            @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
                            {
                                Q_OBJECT
                            
                            public:
                                explicit iosmsgbox(const QString &message,const QString &btn1txt,const QString &btn2txt,const QString &btn3txt,QWidget *parent = 0);
                                ~iosmsgbox();
                                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();
                            
                            private:
                                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) :
                                QDialog(parent),
                                ui(new Ui::iosmsgbox)
                            {
                                ui->setupUi(this);
                                
                                selvalue=0;
                                ui->btn_1->setVisible(!btn1txt.isEmpty());
                                ui->btn_1->setText(btn1txt);
                                ui->btn_2->setVisible(!btn2txt.isEmpty());
                                ui->btn_2->setText(btn2txt);
                                ui->btn_3->setVisible(!btn3txt.isEmpty());
                                ui->btn_3->setText(btn3txt);
                            }
                            
                            iosmsgbox::~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);
                                mymsg->exec();
                                returnvalue=mymsg->selvalue;
                                mymsg->close();
                                delete mymsg;
                                return returnvalue;
                            }
                            
                            void iosmsgbox::on_btn_1_clicked()
                            {
                                selvalue=1;
                                this->hide();
                            }
                            
                            void iosmsgbox::on_btn_2_clicked()
                            {
                                selvalue=2;
                                this->hide();
                            }
                            
                            void iosmsgbox::on_btn_3_clicked()
                            {
                                selvalue=3;
                                this->hide();
                            }
                            
                            

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

                            mrjjM Offline
                            mrjjM Offline
                            mrjj
                            Lifetime Qt Champion
                            wrote on last edited by
                            #13

                            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);
                            mymsg.exec();
                            returnvalue=mymsg.selvalue;
                            mymsg.close();

                            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 ?
                            T 1 Reply Last reply
                            0
                            • mrjjM mrjj

                              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);
                              mymsg.exec();
                              returnvalue=mymsg.selvalue;
                              mymsg.close();

                              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 ?
                              T Offline
                              T Offline
                              TheCrowKaka
                              wrote on last edited by
                              #14

                              @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.

                              A Qt Enthusiastic...

                              1 Reply Last reply
                              1

                              • Login

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • Users
                              • Groups
                              • Search
                              • Get Qt Extensions
                              • Unsolved