Results 1 to 2 of 2

Thread: Message box comes up with wrong icon and no default button

  1. #1
    Join Date
    Jul 2017
    Posts
    37
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Message box comes up with wrong icon and no default button

    Qt Code:
    1. bool TinCanvas::mouseCheckImported()
    2. {
    3. bool ret;
    4. if (doc.pl[plnum].whichBreak0Valid==1)
    5. {
    6. QMessageBox msgBox(this);
    7. msgBox.setText(tr("You have imported breaklines."));
    8. msgBox.setInformativeText(tr("Do you want to edit?"));
    9. msgBox.setStandardButtons(QMessageBox::Yes|QMessageBox::No);
    10. msgBox.setIcon(QMessageBox::Question);
    11. msgBox.setDefaultButton(QMessageBox::No);
    12. ret=msgBox.exec()==QMessageBox::Yes;
    13. }
    14. else
    15. ret=true;
    16. return ret;
    17. }
    To copy to clipboard, switch view to plain text mode 
    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.
    Attached Images Attached Images

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Message box comes up with wrong icon and no default button

    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...
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. QTreeWidgetItem one icon + one icon button
    By Alundra in forum Qt Programming
    Replies: 1
    Last Post: 21st November 2014, 10:29
  2. Qt 4.8.6 windows 7 default wrong style
    By mero in forum Qt Programming
    Replies: 0
    Last Post: 1st May 2014, 13:54
  3. Replies: 2
    Last Post: 26th April 2011, 11:44
  4. system tray message is not displaying near tary icon
    By sudhansu in forum Qt Programming
    Replies: 0
    Last Post: 29th March 2010, 17:31
  5. Icon and another picture looks wrong
    By John-P in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 22nd February 2010, 12:14

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.