我有这些按钮,我试图减小它们的尺寸,但它们拒绝变小。它们都在QHBoxLayout中。 我可以缩小它们只显示+, - ,< - >和欧共体文本?
在布局上:
->setSpacing(1);
->setContentsMargins(1,1,1,1);
->setAlignment(Qt::AlignLeft);
在按钮上:
->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
将按钮添加到布局时:
->addWidget(button, 0, Qt::AlignLeft);
答案 0 :(得分:2)
You can get your buttons a little smaller by removing the padding on the buttons using style sheets.
ui->myPushButton->setStyleSheet( "padding: 0px;" );
I would however strongly advise against using incredibly small buttons. As per Fitt's Law, the smaller a button is, the longer it takes for the User to move their cursor to within the bounds of the button, and the more likely they'll miss and click a neighboring element (made even more likely as there's no padding between the buttons in your example). This leads to user frustration, which is never a good thing.