Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Expanding lineEdit in QHBoxLayout is not working properly in qt plugins

    General and Desktop
    2
    3
    1721
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      alizadeh91 last edited by

      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?

      1 Reply Last reply Reply Quote 0
      • B
        b1gsnak3 last edited by

        if you put

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

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

        1 Reply Last reply Reply Quote 0
        • A
          alizadeh91 last edited by

          Yes!

          1 Reply Last reply Reply Quote 0
          • First post
            Last post