PDA

View Full Version : size of QPushButton



eleanor
4th May 2009, 14:13
Hi...

currently I'm using this code:



/* images - on buttons */
close_icon = QIcon(":/close_image");
send_icon = QIcon(":/send_image");
ok_icon = QIcon(":/ok_image");
notok_icon = QIcon(":/notok_image");

/* buttons */
send_button = new QPushButton(send_icon, "Send");
send_button->setDisabled(true);
quit_button = new QPushButton(close_icon, "Quit");
attach_button = new QPushButton(ok_icon, "Attach more files");
validate_button = new QPushButton(ok_icon, "Validate");

/* buttons layout */
button_layout = new QHBoxLayout();
button_layout->addWidget(send_button);
button_layout->addWidget(quit_button);

/* validate layout */
validate_layout = new QHBoxLayout();
validate_layout->addWidget(attach_button);
validate_layout->addWidget(validate_button);



but if I resize the widget, the buttons are not resized with the widget (layout)... I want to resize buttons with application...so that they consume the whole space that is available.

Any ideas how to do that...thank you!

mcosta
4th May 2009, 14:19
You must add validate_layout and button_layout to the Widget's Layout

eleanor
4th May 2009, 16:45
That's what I did:



/* main layout */
QVBoxLayout *main_layout = new QVBoxLayout();
main_layout->addLayout(validate_layout);
main_layout->addLayout(button_layout);
this->setLayout(main_layout);


but the buttons are not as big as there is space available...they are normal small buttons. I'm sure there are some settings, just don't know which...any other ideas?

eleanor
4th May 2009, 18:21
Ah, I got it:


setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);