Answer the question
In order to leave comments, you need to log in
How to use the size() function in QT Creator?
Hello!
In QT Creator I want to add a button and set its size
QPushButton *button=new QPushButton(this);
button->size(Что сюда нужно писать?);
Answer the question
In order to leave comments, you need to log in
It's not that function. To set the size, you need setGeometry .
It is passed 4 numbers - the coordinates of the upper left corner and the dimensions in pixels.
Or an instance of the QRect class that specifies the position.
In fact, there is no need to resort to this function, the UI must be built so that QT itself sets the size and position of the controls on the form: qtdocs.narod.ru/4.1.0/doc/html/layout.html
QPushButton, like any other widget, has several functions for setting the size:
setMinimumSize(); setMaximumSize(); setFixedSize();
and in them, as you wrote, set the size exactly like this:
QPushButton *button=new QPushButton(this);
button->setFixedSize(100,100);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question