我有一个SignatureEditorForm类,它继承自QDialog类:
SignatureEditorForm(QWidget* parent_widget) : QDialog(parent_widget)
{
resize(SIGNATURE_EDITOR_SIZE);
setWindowTitle(QString("Signature Editor"));
setWindowFlags(Qt::Window | Qt::MSWindowsFixedSizeDialogHint | Qt::WindowCloseButtonHint);
setModal(true);
{
QPushButton* const button = new QPushButton(QString("<"), this);
const QSize BUTTON_SIZE = QSize(22, 22);
button->resize(BUTTON_SIZE);
}
}
它包含一个大小为(宽度:22,高度:22)且标题为“<”的QPushButton。
我有这个小部件(SignatureEditorForm)的图片。QPushButton的大小为(宽度:20,高度:20)。我该如何设置按钮的精确大小?
P.S. 我尝试使用setMinimumSize,但它没有效果。
P.P.S. 这行代码button->setStyleSheet("border: 1px solid black; background: white"); 会产生这样的效果(精确大小)。