Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Expanding lineEdit in QHBoxLayout is not working properly in qt plugins
QtWS25 Last Chance

Expanding lineEdit in QHBoxLayout is not working properly in qt plugins

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.9k Views
  • 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 Offline
    A Offline
    alizadeh91
    wrote on last edited by
    #1

    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
    0
    • B Offline
      B Offline
      b1gsnak3
      wrote on last edited by
      #2

      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
      0
      • A Offline
        A Offline
        alizadeh91
        wrote on last edited by
        #3

        Yes!

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved