Results 1 to 4 of 4

Thread: Unable to get the correct QWidget width after expansion

  1. #1
    Join Date
    Jun 2013
    Posts
    3
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Question Unable to get the correct QWidget width after expansion

    I am trying to embed a Qtreeview inside a QWidget. The user has the choice of expanding the QWidget. The width of the columns in the Qtreeview are calculated based on the current QWidget width. There are 5 columns in the treeview. Each column takes a fraction of the total QWidget width. I am using QWidget::width() function to get the current width of the widget. But even after expansion of the widget I am getting a constant number(100) as the QWidget width. I have also used SetStretchLastSection.

    Illustration of the problem is as follows:

    Normal Treeview Widget:
    Treeview 1.png

    After Expansion:

    Expected Behaviour:
    Treeview 2.png

    Current Behaviour:
    Treeview 3.png

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Unable to get the correct QWidget width after expansion

    Wouldn't it be easier to just set the resize mode for the second column to Stretch?

    Cheers,
    _

  3. #3
    Join Date
    Jun 2013
    Posts
    3
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Unable to get the correct QWidget width after expansion

    I tried that. But the other columns should have their resize mode set to interactive. So, if I set the second column's resize mode as stretch, columns after it gets expanded in the opposite direction.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Unable to get the correct QWidget width after expansion

    Ok, I'll probably don't fully understand your objectives.
    But why do you use the parent widget's width and not that of the treeview itself?

    Cheers,
    _

Similar Threads

  1. Unable to add QToolButton to QToolbar on QWidget
    By rawfool in forum Qt Programming
    Replies: 0
    Last Post: 17th August 2012, 10:52
  2. Replies: 5
    Last Post: 28th November 2011, 07:20
  3. Expansion rules for a blank widget
    By dohzer in forum Newbie
    Replies: 4
    Last Post: 12th August 2010, 16:07
  4. Unable to update QTableWidget which is on Different QWidget from MainWindow
    By sagar.mangalwedhekar in forum Qt Programming
    Replies: 1
    Last Post: 12th March 2010, 07:07
  5. QWidget with fixed width height ratio
    By Lodorot in forum Qt Programming
    Replies: 1
    Last Post: 26th May 2009, 08:49

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.