How to set QWidget width?

Narek picture Narek · Jun 3, 2010 · Viewed 66.7k times · Source

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?

Answer

JimDaniel picture JimDaniel · Jun 3, 2010

resize() might be better to use.

Example usage:

widget->resize(165, widget->height());