Expanding lineEdit in QHBoxLayout is not working properly in qt plugins



  • HI,
    I've created a qt plugin with comboBox and lineEdit and put them in QHBoxLayout in Qt5. when i set sizepolicy of lineEdit to expanding, it doesn't works properly. actually it expands itself a little.

    my code in plugin constructor in something like below:
    Qt Code: Switch view
    @comboBoxUnits = new QComboBox;
    lineEditValue = new QLineEdit;

    horizontalLayout = new QHBoxLayout(this);
    horizontalLayout->setMargin(1);
    
    comboBoxUnits->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed);
    lineEditValue->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
    
    horizontalLayout->addWidget(lineEditValue,0,Qt::AlignLeft);
    horizontalLayout->addWidget(comboBoxUnits,0,Qt::AlignRight);
    
    this->setLayout(horizontalLayout);@
    

    what i am missing?



  • if you put

    @comboBoxUnits->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);@

    and set a Fixed width for comboBox does it still behave wrongly?



  • Yes!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.