A
A
Alexander Sharomet2014-11-21 18:04:33
Programming
Alexander Sharomet, 2014-11-21 18:04:33

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(Что сюда нужно писать?);

Usually sizes are written with a comma size(100,100) but I keep getting an error...
How to use this function correctly? If possible an example. Thank you!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Armenian Radio, 2014-11-21
@gbg

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

V
Vitaly Azovsky, 2014-11-27
@Vorotislav

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);

The size() function returns the current size of the button.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question