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. QLineEdit doesn't fully expand on Mac
Forum Updated to NodeBB v4.3 + New Features

QLineEdit doesn't fully expand on Mac

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 720 Views 2 Watching
  • 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.
  • E Offline
    E Offline
    efremdan1
    wrote on last edited by
    #1

    I'm finding that my QLineEdit widgets are not fully expanding to the space available, even when the horizontal size policy is set to Expanding. This makes my application look strange. It occurs both when I run a code straight from Python or when I use the Tools -> Form Editor -> Preview in -> macintosh Style in Qt Creator.

    Any workarounds? Is this a bug I should report?

    I'm using Qt 5.15.2 (I don't think other details are pertinent since the error occurs in Qt Creator preview, but I'm running macOS 10.15.7). Minimal working example follows.

    import sys
    from PySide2.QtWidgets import *
    from PySide2.QtCore import Qt
    
    def window():
       app = QApplication(sys.argv)
       win = QWidget()
    
       l1 = QLabel("Name")
       nm = QLineEdit()
    
       l2 = QLabel("Info")
       add1 = QTextEdit()
       fbox = QFormLayout()
       fbox.addRow(l1,nm)
       vbox = QVBoxLayout()
    
       vbox.addWidget(add1)
       fbox.addRow(l2,vbox)
       hbox = QHBoxLayout()
    
       r1 = QRadioButton("Male")
       r2 = QRadioButton("Female")
       hbox.addWidget(r1)
       hbox.addWidget(r2)
       hbox.addStretch()
       fbox.addRow(QLabel("sex"),hbox)
       fbox.addRow(QPushButton("Submit"),QPushButton("Cancel"))
    
       win.setLayout(fbox)
    
       win.setWindowTitle("PyQt")
       win.show()
       sys.exit(app.exec_())
    
    if __name__ == '__main__':
       window()
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #5

      Hi,

      You can modify the field growth policy to match the effect you want. Note that you will go against your platform GUI guidelines.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • E Offline
        E Offline
        efremdan1
        wrote on last edited by
        #2

        Here's a minimal working example UI file for opening in Qt Creator.

        <?xml version="1.0" encoding="UTF-8"?>
        <ui version="4.0">
         <class>test</class>
         <widget class="QMainWindow" name="test">
          <property name="geometry">
           <rect>
            <x>0</x>
            <y>0</y>
            <width>800</width>
            <height>600</height>
           </rect>
          </property>
          <property name="windowTitle">
           <string>test</string>
          </property>
          <widget class="QWidget" name="centralwidget">
           <layout class="QVBoxLayout" name="verticalLayout">
            <item>
             <layout class="QFormLayout" name="formLayout_23">
              <item row="0" column="1">
               <widget class="QLabel" name="label_77"/>
              </item>
              <item row="1" column="0">
               <widget class="QLabel" name="label_83">
                <property name="text">
                 <string>Title</string>
                </property>
               </widget>
              </item>
              <item row="2" column="0">
               <widget class="QLabel" name="label_79">
                <property name="text">
                 <string>Notes</string>
                </property>
               </widget>
              </item>
              <item row="1" column="1">
               <widget class="QLineEdit" name="lineEdit"/>
              </item>
              <item row="2" column="1">
               <widget class="QPlainTextEdit" name="plainTextEdit"/>
              </item>
              <item row="0" column="0">
               <widget class="QLabel" name="label_74">
                <property name="text">
                 <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; text-decoration: underline;&quot;&gt;Include&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
                </property>
               </widget>
              </item>
             </layout>
            </item>
           </layout>
          </widget>
          <widget class="QMenuBar" name="menubar">
           <property name="geometry">
            <rect>
             <x>0</x>
             <y>0</y>
             <width>800</width>
             <height>22</height>
            </rect>
           </property>
          </widget>
          <widget class="QStatusBar" name="statusbar"/>
         </widget>
         <resources/>
         <connections/>
        </ui>
        
        1 Reply Last reply
        0
        • M Offline
          M Offline
          mpergand
          wrote on last edited by
          #3

          Hi,
          You are using QFormLayout, you should use QVBoxLayout instead.

          E 1 Reply Last reply
          0
          • M mpergand

            Hi,
            You are using QFormLayout, you should use QVBoxLayout instead.

            E Offline
            E Offline
            efremdan1
            wrote on last edited by
            #4

            @mpergand
            I'm rather confused by the suggestion. I'm trying to create a form with 2 columns (one column of labels, and one column of input widgets). How would I do this with a QVBoxLayout? If I first made each of the rows its own layout with a QHBoxLayout and then put all the rows into a QVBoxLayout, the labels won't line up...

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #5

              Hi,

              You can modify the field growth policy to match the effect you want. Note that you will go against your platform GUI guidelines.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              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