Problem with QMessagebox with IOS.. Application becomes unresponsive
-
wrote on 17 Dec 2018, 18:23 last edited by
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=trueHowever 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.
-
Hi
What Qt version are you using ?
Also did you try Qt::QueuedConnection as mentioned. -
wrote on 18 Dec 2018, 00:42 last edited by
@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? -
wrote on 18 Dec 2018, 01:43 last edited by
@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?
-
wrote on 18 Dec 2018, 01:52 last edited by
@mrjj My IOS version is 11.4.1
-
@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?
@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. -
@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.wrote on 18 Dec 2018, 11:43 last edited by@mrjj manually adding a new action and using QueuedConnection to test also did not work.
-
@mrjj manually adding a new action and using QueuedConnection to test also did not work.
@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 ? -
@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 ?wrote on 18 Dec 2018, 12:07 last edited by@mrjj I am using Qt5.10.1
-
@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 ?wrote on 18 Dec 2018, 12:40 last edited by@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? -
@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?@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. -
@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.wrote on 18 Dec 2018, 13:52 last edited by@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.
-
@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.
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 ?
-
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 ?
wrote on 18 Dec 2018, 16:22 last edited by@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.
1/14