I am trying to do something that looks easy, but I cannot make it working. I want to make buttons bigger in my QWizard. Here is the code :
#include "wizard.h"
#include "ui_wizard.h"
#include "QAbstractButton"
Wizard::Wizard(QWidget *parent) :
QWizard(parent),
ui(new Ui::Wizard)
{
ui->setupUi(this);
QRect rect = this->button(QWizard::NextButton)->geometry();
this->button(QWizard::NextButton)->setGeometry(rect.x(), rect.y(), rect.width(), 40);
rect = this->button(QWizard::CancelButton)->geometry();
this->button(QWizard::CancelButton)->setGeometry(rect.x(), rect.y(), rect.width(), 40);
rect = this->button(QWizard::BackButton)->geometry();
this->button(QWizard::BackButton)->setGeometry(rect.x(), rect.y(), rect.width(), 40);
}
Wizard::~Wizard()
{
delete ui;
}
This code does nothing. Is it possible to change the geometry of the buttons? Or it is forbidden?
Thank you
Better is to customize user interface using QSS (Qt Style Sheet). You can read your qss file and setup stylesheet for the whole application using QApplication::setStyleSheet().
Also you can setup qss programmatically (not the best practics).
setStyleSheet("QAbstractButton { height: 50px }");
What sets height for all buttons on the widget.
In the worst case you can try this:
button(QWizard::CancelButton)->setStyleSheet("height: 50px");