Results 1 to 9 of 9

Thread: QMessageBox: Controlling the width

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Question QMessageBox: Controlling the width

    Hi All,

    This is a complete noob question and I'm no doubt going to smack my forehead when I hear the answer.

    I am creating a QMessageBox in various places to present errors and warnings. The boxes seem to have a mind of their own when it comes to sizing (width) and often wrap poorly or truncate the window title. I have tried using setMinimumWidth() but it does not seem to have any effect. Code looks like:
    Qt Code:
    1. #include <QtGui>
    2. #include <QDebug>
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6.  
    7. QApplication app(argc, argv);
    8.  
    9. QMessageBox msgBox1;
    10. msgBox1.setMinimumWidth(400); // seemingly ignored, always same width box
    11. msgBox1.setWindowTitle("Width 400");
    12. msgBox1.setText("<strong>Warning</strong>");
    13. msgBox1.setInformativeText(
    14. "You have not entered hours against this event<br /> "
    15. "Do you wish to save the event anyway?");
    16. msgBox1.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
    17. msgBox1.setDefaultButton(QMessageBox::No);
    18. msgBox1.setIcon(QMessageBox::Warning);
    19. msgBox1.show();
    20.  
    21. QMessageBox msgBox2;
    22. msgBox2.setMinimumWidth(800); // seemingly ignored, always same width box
    23. msgBox2.setWindowTitle("Width 800");
    24. msgBox2.setText("<strong>Warning</strong>");
    25. msgBox2.setInformativeText(
    26. "You have not entered hours against this event<br /> "
    27. "Do you wish to save the event anyway?");
    28. msgBox2.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
    29. msgBox2.setDefaultButton(QMessageBox::No);
    30. msgBox2.setIcon(QMessageBox::Warning);
    31. msgBox2.exec();
    32.  
    33. return app.exec();
    34. }
    35.  
    36. // vi: sw=4 ts=4 et
    To copy to clipboard, switch view to plain text mode 

    The result is attached. What is the obvious thing I'm missing?

    Chris
    Attached Images Attached Images

Similar Threads

  1. QMessageBox misbehaves after QFileDialog call
    By MikeG in forum Qt Programming
    Replies: 8
    Last Post: 2nd June 2009, 10:17
  2. Replies: 4
    Last Post: 15th October 2008, 13:24
  3. Scaling of pen width in QGraphicsView
    By spuds in forum Qt Programming
    Replies: 3
    Last Post: 30th May 2008, 01:47
  4. QTableWidget column width and resizing
    By shooogun in forum Qt Programming
    Replies: 2
    Last Post: 16th March 2008, 22:31
  5. How to obtain the width of a QTableWidget?
    By Giel Peters in forum Qt Programming
    Replies: 3
    Last Post: 9th January 2006, 22:34

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
  •  
Qt is a trademark of The Qt Company.