Results 1 to 4 of 4

Thread: Expanding lineEdit in QHBoxLayout is not working properly in qt plugins

  1. #1
    Join Date
    Jan 2012
    Location
    Iran, Tehran
    Posts
    308
    Thanks
    75
    Thanked 24 Times in 21 Posts
    Qt products
    Qt4 Qt5 PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Default 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:
    Untitled-4.png

    my code in plugin constructor is something like below:
    Qt Code:
    1. comboBox = new QComboBox;
    2. lineEditValue = new QLineEdit;
    3.  
    4. horizontalLayout = new QHBoxLayout(this);
    5. horizontalLayout->setMargin(1);
    6.  
    7. comboBox->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed);
    8. lineEditValue->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
    9.  
    10. horizontalLayout->addWidget(lineEditValue,0,Qt::AlignLeft);
    11. horizontalLayout->addWidget(comboBox,0,Qt::AlignRight);
    12.  
    13. this->setLayout(horizontalLayout);
    To copy to clipboard, switch view to plain text mode 
    what i am missing?
    Last edited by alizadeh91; 27th January 2013 at 16:10.

  2. #2
    Join Date
    Jan 2012
    Location
    Iran, Tehran
    Posts
    308
    Thanks
    75
    Thanked 24 Times in 21 Posts
    Qt products
    Qt4 Qt5 PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Default Re: Expanding lineEdit in QHBoxLayout is not working properly in qt plugins

    Any hint?! mybe i have to use ui file instead of creating comboBox and lineEdit in code? Can i create them in ui file inside of plugin?!

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Expanding lineEdit in QHBoxLayout is not working properly in qt plugins

    Try this:
    do not change the size policy of either widget, but use a stretch > 0 on the line edit

    Qt Code:
    1. horizontalLayout->addWidget(lineEditValue, 1);
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

  4. The following user says thank you to anda_skoa for this useful post:

    alizadeh91 (29th January 2013)

  5. #4
    Join Date
    Jan 2012
    Location
    Iran, Tehran
    Posts
    308
    Thanks
    75
    Thanked 24 Times in 21 Posts
    Qt products
    Qt4 Qt5 PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Default Re: Expanding lineEdit in QHBoxLayout is not working properly in qt plugins

    Thanks but it didn't worked either!


    Added after 11 minutes:


    Maybe something is wrong when it is in a plugin?
    Last edited by alizadeh91; 30th January 2013 at 08:37.

Similar Threads

  1. virtual keyboard and lineedit are not working together
    By kinjalp in forum Qt Programming
    Replies: 0
    Last Post: 23rd February 2012, 12:37
  2. QToolbar expanding sizePolicy not working properly
    By sfcheng77 in forum Qt Programming
    Replies: 2
    Last Post: 22nd February 2011, 23:50
  3. memcpy not working properly
    By sattu in forum Qt Programming
    Replies: 3
    Last Post: 26th October 2010, 23:33
  4. Connection not properly done.... lineEdit
    By hipogrito in forum Newbie
    Replies: 4
    Last Post: 2nd April 2007, 21:53
  5. Replies: 1
    Last Post: 28th February 2007, 08:34

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.