PDA

View Full Version : QWidget size at run time



mvbhavsar
31st January 2014, 04:34
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

ChrisW67
31st January 2014, 06:06
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.

mvbhavsar
31st January 2014, 08:40
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

ChrisW67
1st February 2014, 00:32
Then you are not calling size() on the object you think you are.