Results 1 to 4 of 4

Thread: QWidget size at run time

  1. #1
    Join Date
    Jun 2010
    Posts
    97
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QWidget size at run time

    Hi,

    I am using QGraphicsView in my code. This QGraphicsView is embedded into QTabWidget which is covering 70% of maximized main window. Now I want to have QGraphicsRectItem in QGraphicsView which will have width and height of QTabWidget at any point in time. But I am getting is design time size of QTabWidget when I use size() method. As QTabWidget is in layout, it will resize as the parent window resizes. So I want size of resized QTabWidget at run time.
    Can anybody help me on this.


    Thanks

    Manish

  2. #2
    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

    Default Re: QWidget size at run time

    QWidget::size() gives you the current size of a widget. If the widget is not yet shown then no layout has adjusted its size and you will usually get the "design time size" as you put it. If you need the size of the widget as shown then you need to call size() after the widget is visible.

  3. #3
    Join Date
    Jun 2010
    Posts
    97
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QWidget size at run time

    Hi Chris,

    QWidget is visible and is adjusted by layout. But despite that it shows design time size only when we call size() function.


    Thanks

    Manish

  4. #4
    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

    Default Re: QWidget size at run time

    Then you are not calling size() on the object you think you are.

Similar Threads

  1. Replies: 5
    Last Post: 22nd December 2011, 07:23
  2. QGridLayout size not the same the second time
    By rperezalejo in forum Qt Programming
    Replies: 3
    Last Post: 27th September 2011, 02:55
  3. Replies: 1
    Last Post: 27th April 2011, 10:35
  4. How to load a Qwidget in groupBox at run time?
    By AviMittal in forum Qt Programming
    Replies: 8
    Last Post: 25th June 2009, 11:35
  5. Display a QWidget on two X-Server at the same time
    By tarod in forum Qt Programming
    Replies: 0
    Last Post: 1st July 2008, 12:55

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.