[Qt-interest] Height of QPushButton and QLineEdit different

Oliver Demetz forenbeitraege at oliverdemetz.de
Tue Jun 9 10:27:42 CEST 2009


Hi all,

Simple example:

   QHBoxLayout * lay = new QHBoxLayout;
   lay->addWidget(new QPushButton("Hello World"));
   lay->addWidget(new QLineEdit("Foo Bar"));
   this->setLayout(lay);

Executing this code, you will see, that the QLineEdit's
height is smaller than the QPushButton's height.

I think it depends on the particular system, but on
my Windows box here the button has height 28 whereas
the lineedit only has 22 pixels.

*How can I adjust this???*

I tried several things:

(A:)  lineedit->setMinimumSize(button->height());
     Didn't change anything.

(B:)  lineedit->setMinimumHeight(button->height());
       lineedit->setMaximumHeight(button->height());
      Leads to crap, the lineedit gets a huge height,
      I don't know why.

(C:)  lineedit.setSizePolicy(
                 lineedit.sizePolicy().horizontalPolicy(),
                 QSizePolicy::Ignored);
       The idea is to make the lineedit *expand* in the
       layout in vertical direction, but this leads also
       to a way too huge height

Why are the recommended heights for these two controls
different at all?

Thanks for your clarifications in advance,
best regards,
Oliver



More information about the Qt-interest-old mailing list