我正在试着做一些看起来很简单的事情,但是我不能让它工作。我想在我的QWizard中做更大的按钮。代码如下:
#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;
}这段代码什么也不做。是否可以更改按钮的几何形状?或者这是被禁止的?
谢谢
发布于 2013-05-08 03:06:51
更好的方法是使用QSS (Qt样式表)定制用户界面。您可以使用QApplication::setStyleSheet()读取qss文件并设置整个应用程序的样式表。
您还可以通过编程方式设置qss (不是最佳实践)。
setStyleSheet("QAbstractButton { height: 50px }");设置小工具上所有按钮的高度。
在最坏的情况下,你可以尝试这样做:
button(QWizard::CancelButton)->setStyleSheet("height: 50px");https://stackoverflow.com/questions/16425575
复制相似问题