Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set QWidget width?

Tags:

c++

qt

qwidget

How to set QWidget width? I know setGeometry(QRect& rect) function to do that, but in that case I should use geometry() function to get former parameters of my QWidget, then I should increment the width and use setGeometry(..). Is there any direct way to that, say:

QWidget aa; aa.setWidth(165); //something like this? 
like image 884
Narek Avatar asked Jun 03 '10 14:06

Narek


People also ask

How do I change the size of a widget in Qt?

If the width won't change afterwards, you can use setFixedWidth : widget->setFixedWidth(165); Similarly, to change the height without changing the width, there is setFixedHeight . Never use fixed width!

What is QWidget class window?

The QWidget class is the base class of all user interface objects.

What is QWidget in Qt?

Widgets are the primary elements for creating user interfaces in Qt. Widgets can display data and status information, receive user input, and provide a container for other widgets that should be grouped together. A widget that is not embedded in a parent widget is called a window.

What is QWidget * parent?

The tree-like organization of QWidgets (and in fact of any QObjects ) is part of the memory management strategy used within the Qt-Framework. Assigning a QObject to a parent means that ownership of the child object is transferred to the parent object. If the parent is deleted, all its children are also deleted.


1 Answers

resize() might be better to use.

Example usage:

widget->resize(165, widget->height()); 
like image 75
JimDaniel Avatar answered Sep 21 '22 08:09

JimDaniel