Results 1 to 6 of 6

Thread: QDialog resize ?

  1. #1
    Join Date
    May 2006
    Posts
    33
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default QDialog resize ?

    I have a QDialog that I'm using to display a tableWidget. The tableWidget contents are the result of a database query. In another dialog the user selects a series of checkboxes that ultimatley determines the query and each checkbox represents a column from a database table. So, I made the QDialog box that holds the tableWidget really wide but depending on which checkboxes the user clicks, I may only display 1 column or up to 10 columns. My question is, how do I programatically set the Dialog's width based on the width of the tableWidget? When I only have a few columns to display there's a lot of white space to the right of the last column.

    TIA.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QDialog resize ?

    QWidget::resize() is a nice way to change the size of a widget and to calculate the proper width you'll have to fetch the header of the table, calculate the width of all columns based on the header, add the frame of the view to the result, add the margin between the dialog border and the view, add the width of the dialog border and set that as the width of the dialog. Or you can set the size of the table widget in a similar manner (without everything that is related to the dialog) and put a constraint on the dialog's layout so that its size is fixed on its contents size.

  3. #3
    Join Date
    May 2006
    Posts
    33
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QDialog resize ?

    OK, thanks. But I'm a little unclear on how the best way to get the "width of all columns based on the header, add the frame of the view to the result, add the margin between the dialog border and the view, add the width of the dialog border".

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QDialog resize ?

    Have you seen QHeaderView docs?

  5. #5
    Join Date
    May 2006
    Posts
    33
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QDialog resize ?

    OK, got the headerView->length(). What about the other 3 parameters you mentioned (add the frame of the view to the result, add the margin between the dialog border and the view, add the width of the dialog border)?

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QDialog resize ?

    I'm not sure length() is what you are after. It depends on how your view is set up. Other parameters need to be gathered from different classes - the layout, the style and the widget. I suggest you try a simpler approach - by setting the size of the table widget and forcing the dialogs layout to adjust to it. You'll just need the frame size then.

Similar Threads

  1. QDialog resize ?
    By allensr in forum Qt Programming
    Replies: 6
    Last Post: 28th October 2007, 22:41
  2. QGraphicsScene / QGraphicsView speed after resize
    By themolecule in forum Qt Programming
    Replies: 1
    Last Post: 21st July 2007, 23:46
  3. Resizing a QDialog to the content size
    By Nyphel in forum Qt Programming
    Replies: 8
    Last Post: 15th March 2007, 08:16
  4. Custom Shape Widget (resize)
    By PiXeL16 in forum Qt Programming
    Replies: 7
    Last Post: 12th February 2007, 07:00
  5. postponing resize event
    By Honestmath in forum Qt Programming
    Replies: 11
    Last Post: 26th February 2006, 00:32

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.