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. Problems using qsizepolicy in a qgridayout
QtWS25 Last Chance

Problems using qsizepolicy in a qgridayout

Scheduled Pinned Locked Moved Unsolved General and Desktop
qsizepolicy
2 Posts 2 Posters 479 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.
  • W Offline
    W Offline
    willemf
    wrote on 27 Jul 2019, 14:42 last edited by
    #1

    0_1564237711576_Screenshot from 2019-07-27 16-19-57.png
    The above image shows part of a larger gridlayout. The leftmost item at the bottom row ("Surface waves") is the problem. The top lefthand item ("Air temp.") is wider than the righthand items. I wish "Surface waves" to have the same width as "Air temp." I have spent a whole day on this without any success. I have used about all possible values for the size policy of "Surface waves" but have not had any success. Following is my code for the item "Surface waves".

       <item row="1" column="0" alignment="Qt::AlignLeft">
        <widget class="QGroupBox" name="groupBox_waves">
         <property name="title">
          <string>Surface waves</string>
         </property>
         <property name="alignment">
          <set>Qt::AlignHCenter</set>
         </property> 
    
         <property name="sizePolicy">
          <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
           <horstretch>1</horstretch>
           <verstretch>0</verstretch>
          </sizepolicy>
         </property>
    
         <layout class="QGridLayout" name="surfaceWavesLayout">
          <property name="verticalSpacing">
           <number>0</number>
          </property>
          <item row="0" column="0" colspan="2" alignment="Qt::AlignHCenter">
           <widget class="StarWidget" name="waves" native="true">
            <property name="focusPolicy">
             <enum>Qt::StrongFocus</enum>
            </property>
            <property name="sizePolicy">
             <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
              <horstretch>0</horstretch>
              <verstretch>0</verstretch>
             </sizepolicy>
            </property>
    
           </widget>
          </item>
          <item row="1" column="0" alignment="Qt::AlignLeft">
           <widget class="QLabel" name="waveLabel1">
            <property name="text">
             <string>Small</string>
            </property>
           </widget>
           </item>
           <item row="1" column="1" alignment="Qt::AlignRight">
            <widget class="QLabel" name="waveLabel2">
             <property name="text">
              <string>Large</string>
             </property>
           </widget>
          </item>
         </layout>
        </widget>
       </item>
    

    I hope this gives sufficient information to locate my problem. I would appreiate any suggestions. Kind regards, willem

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on 29 Jul 2019, 15:08 last edited by
      #2

      It's probably because of the alignment you set to Qt::AlignLeft. This alignment is for cases when you don't want an item to fill grid's cell or it has a maximum size smaller than the cell. It then says which border do you want your item to stick to.

      If you want it to fill the cell leave it at default i.e. remove alignment="Qt::AlignLeft" from item definition.

      1 Reply Last reply
      3

      1/2

      27 Jul 2019, 14:42

      • Login

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