Reputation: 972
I have these pushbuttons and I have tried to minimize their sizes, but they refuse to go any smaller. They are all in a QHBoxLayout. Can I shrink them to just show the +, the -, the <-> and the EC texts?
On the layout:
->setSpacing(1);
->setContentsMargins(1,1,1,1);
->setAlignment(Qt::AlignLeft);
On the buttons themselves:
->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
When adding the buttons to the layout:
->addWidget(button, 0, Qt::AlignLeft);
Upvotes: 0
Views: 502
Reputation: 2542
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.
Upvotes: 2