PDA

View Full Version : Message box comes up with wrong icon and no default button



PierreA
31st December 2017, 11:06
bool TinCanvas::mouseCheckImported()
{
bool ret;
if (doc.pl[plnum].whichBreak0Valid==1)
{
QMessageBox msgBox(this);
msgBox.setText(tr("You have imported breaklines."));
msgBox.setInformativeText(tr("Do you want to edit?"));
msgBox.setStandardButtons(QMessageBox::Yes|QMessag eBox::No);
msgBox.setIcon(QMessageBox::Question);
msgBox.setDefaultButton(QMessageBox::No);
ret=msgBox.exec()==QMessageBox::Yes;
}
else
ret=true;
return ret;
}
When I run the program and click on an edge after importing breaklines, this message box pops up, but its icon is (i), not (?), and neither button looks like the default. I've tested it and found that the default button is, in fact, "No".

I'm running Kubuntu Xenial; "ldd `which kate`" shows that it is using Qt5, as is my program.

high_flyer
1st January 2018, 12:27
Regarding the icon, the docs mention that:

The pixmap used to display the actual icon depends on the current GUI style. You can also set a custom pixmap for the icon by setting the icon pixmap property.
So maybe its a style issue.

You can try to use the convenience static method QMessageBox::question()
http://doc.qt.io/qt-5/qmessagebox.html#question

Will also save you all the code you have there at the moment...