(QSS) Why are two QPushButtons of different height if both are sized relative to their text height using "em" as unit
-
I have two QPushButtons, both H/V size policies are set to "Fixed", they sit next to one another in a QHBoxLayout and my QSS for QPushButton is this:
QPushButton { background-color: #3c9eb8; border: none; font-family: "Segoe UI"; font-size: 8pt; color: white; outline: none; padding-left: 1.0em; padding-right: 1.0em; min-height: 2em; min-width: 4em; }
This is the result:
How can they be of different height if the height is based on the font size, which is the same for both?
I'm using Qt5.9 on Windows 10. -
Hi,
You should add which Qt version you are using and the OS as well.
-
Can you share how you create the buttons ?
-
I'm not sure if this is affecting it, but 'Open' has a descending character, p, whereas 'New' does not. I would still expect the buttons to have the same height if you created them the same way.
-
@SGaist said in (QSS) Why are two QPushButtons of different height if both are sized relative to their text height using "em" as unit:
Can you share how you create the buttons ?
Sure:
m_p_new_button = new QPushButton; m_p_new_button->setText(tr("New")); m_p_new_button->setEnabled(true); m_p_new_button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); m_p_open_button = new QPushButton; m_p_open_button->setText(tr("Open")); m_p_open_button->setEnabled(false); // Enabled dynamically m_p_open_button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); QHBoxLayout* p_button_layout = new QHBoxLayout; p_button_layout->setSpacing(5); p_button_layout->addWidget(m_p_new_button); p_button_layout->addWidget(m_p_open_button);