Results 1 to 2 of 2

Thread: How to set minimum width of a dialog that derived from QMessageBox (All I try failed)

  1. #1
    Join Date
    Feb 2012
    Posts
    8
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default How to set minimum width of a dialog that derived from QMessageBox (All I try failed)

    I have a class drived from QMessageBox, and the size of the dialog is set by default, I want it to be wider and have a better look (less word wrap). Of course, setMinimumWidth() or setFixedSize() don't work, the size is automatically computed by QMessageBox. I searched the web, someone said that overwrite showEvent() or resizeEvent() could do, I've tried but it had no effect, my QT version is 4.7, maybe that method only works with older Qt. I also found an ugly way to set the minimum size, that is, adding many spaces to window title, at last I find it's not a workaround, since there is always three dot "..." at the end of the title bar, not user friendly. Our project had used a lot of such derived message box, it's not a good idea to write a new one, I want to know is there any other way to change the size?

  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: How to set minimum width of a dialog that derived from QMessageBox (All I try fai

    If you are under windows, then you can remove the Qt::MSWindowsFixedSizeDialogHint from the constructor which is set by default.
    (I am not 100% this actually limits the dialog size or is it only a style used usually for fixed sized dialogs - but you can try it)
    I don't have a way of testing this at the moment but my guess is that the QMessageBox is setting its size policy to fixed by default.
    Try setting the size policy to something else and then set a new geometry/size.
    I want it to be wider and have a better look (less word wrap).
    What you mean by "less"?
    It will either word wrap or it wont - how can it be less or more?
    You might want to have a look at QMessageBox::setTextFormat()
    ==========================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. QMessageBox: Controlling the width
    By ChrisW67 in forum Newbie
    Replies: 8
    Last Post: 14th August 2009, 22:38
  2. resize Dialog to minimum height
    By pospiech in forum Qt Programming
    Replies: 7
    Last Post: 25th June 2009, 14:04
  3. Use QWidget derived class in Dialog
    By qtneuling in forum Qt Tools
    Replies: 2
    Last Post: 17th May 2008, 23:29
  4. Forcing a minimum list widget width
    By MrGarbage in forum Qt Tools
    Replies: 1
    Last Post: 14th July 2007, 17:16
  5. QTable column stretchable with minimum Width
    By sunil.thaha in forum Qt Programming
    Replies: 0
    Last Post: 24th April 2006, 13:17

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.