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. [SOLVED] remove the space in between the buttons

[SOLVED] remove the space in between the buttons

Scheduled Pinned Locked Moved General and Desktop
18 Posts 6 Posters 14.2k 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.
  • K Offline
    K Offline
    kalster
    wrote on 26 Aug 2011, 06:23 last edited by
    #1

    in the form designer, i have a textEdit and 3 buttons with a vertical spacer beside the buttons and a layout to a grid. the space in between the buttons is about 13 pixels. how to remove the space in between the buttons. i have tried this->layout()->setSpacing(0); but that does not work.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      maxim.prishchepa
      wrote on 26 Aug 2011, 06:28 last edited by
      #2

      try set spacing to layout which contains buttons.

      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz).

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kalster
        wrote on 26 Aug 2011, 06:36 last edited by
        #3

        i have tried ui->pushbutton->layout()->setSpacing(0); which crashes the program at compile time.

        1 Reply Last reply
        0
        • R Offline
          R Offline
          Robbin
          wrote on 26 Aug 2011, 06:52 last edited by
          #4

          I guess maxim meant that you create new layout with your buttons inside and sort the spacing in there, not to try setting spacing on the button itself.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andre
            wrote on 26 Aug 2011, 06:52 last edited by
            #5

            Because the pushbutton is in a layout, it most probably does not have one.

            1 Reply Last reply
            0
            • K Offline
              K Offline
              kalster
              wrote on 26 Aug 2011, 07:02 last edited by
              #6

              [quote author="Eus" date="1314341521"]I guess maxim meant that you create new layout with your buttons inside and sort the spacing in there, not to try setting spacing on the button itself.[/quote]

              Eus, i don't understand what you are saying. are you saying to set spacing in the form designer. I can't find any spacing settings in there

              1 Reply Last reply
              0
              • E Offline
                E Offline
                Eddy
                wrote on 26 Aug 2011, 07:14 last edited by
                #7

                You could go to the properties of the layout that holds your widgets and set contentmargins.

                Qt Certified Specialist
                www.edalsolutions.be

                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  Robbin
                  wrote on 26 Aug 2011, 07:15 last edited by
                  #8

                  All the three people here are saying the same kalster - create another layout VBox HBox or group, with your buttons only. On that new layout create your spacing.

                  1 Reply Last reply
                  0
                  • L Offline
                    L Offline
                    lgeyer
                    wrote on 26 Aug 2011, 07:18 last edited by
                    #9

                    Because ui->pushbutton has no layout set. It has to be ui->nameOfTheLayoutContainingTheButtons->setSpacing(0);

                    In doubt please post your generated ui code.

                    1 Reply Last reply
                    0
                    • K Offline
                      K Offline
                      kalster
                      wrote on 26 Aug 2011, 07:30 last edited by
                      #10

                      Lukas Geyer, no properties for setSpacing in ui->nameOfTheLayoutContainingTheButtons->setSpacing(0);. layout()->setspacing does not work.

                      here is my ui code
                      @<?xml version="1.0" encoding="UTF-8"?>
                      <ui version="4.0">
                      <class>MainWindow</class>
                      <widget class="QMainWindow" name="MainWindow">
                      <property name="geometry">
                      <rect>
                      <x>0</x>
                      <y>0</y>
                      <width>400</width>
                      <height>300</height>
                      </rect>
                      </property>
                      <property name="windowTitle">
                      <string>MainWindow</string>
                      </property>
                      <widget class="QWidget" name="centralWidget"/>
                      <widget class="QMenuBar" name="menuBar">
                      <property name="geometry">
                      <rect>
                      <x>0</x>
                      <y>0</y>
                      <width>400</width>
                      <height>20</height>
                      </rect>
                      </property>
                      </widget>
                      <widget class="QToolBar" name="mainToolBar">
                      <attribute name="toolBarArea">
                      <enum>TopToolBarArea</enum>
                      </attribute>
                      <attribute name="toolBarBreak">
                      <bool>false</bool>
                      </attribute>
                      </widget>
                      <widget class="QStatusBar" name="statusBar"/>
                      <widget class="QDockWidget" name="dockWidget">
                      <attribute name="dockWidgetArea">
                      <number>1</number>
                      </attribute>
                      <widget class="QWidget" name="dockWidgetContents">
                      <layout class="QGridLayout" name="gridLayout">
                      <item row="0" column="0" colspan="3">
                      <widget class="QPlainTextEdit" name="plainTextEdit"/>
                      </item>
                      <item row="1" column="0">
                      <widget class="QPushButton" name="pushButton">
                      <property name="sizePolicy">
                      <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
                      <horstretch>0</horstretch>
                      <verstretch>0</verstretch>
                      </sizepolicy>
                      </property>
                      <property name="text">
                      <string>PushButton</string>
                      </property>
                      </widget>
                      </item>
                      <item row="1" column="2">
                      <spacer name="horizontalSpacer">
                      <property name="orientation">
                      <enum>Qt::Horizontal</enum>
                      </property>
                      <property name="sizeHint" stdset="0">
                      <size>
                      <width>72</width>
                      <height>20</height>
                      </size>
                      </property>
                      </spacer>
                      </item>
                      <item row="1" column="1">
                      <widget class="QPushButton" name="pushButton_2">
                      <property name="text">
                      <string>PushButton</string>
                      </property>
                      </widget>
                      </item>
                      </layout>
                      </widget>
                      </widget>
                      </widget>
                      <layoutdefault spacing="6" margin="11"/>
                      <resources/>
                      <connections/>
                      </ui>
                      @

                      1 Reply Last reply
                      0
                      • K Offline
                        K Offline
                        kalster
                        wrote on 26 Aug 2011, 07:33 last edited by
                        #11

                        [quote author="Eus" date="1314342906"]All the three people here are saying the same kalster - create another layout VBox HBox or group, with your buttons only. On that new layout create your spacing.[/quote]

                        but i need the textEdit in the layout.

                        1 Reply Last reply
                        0
                        • R Offline
                          R Offline
                          Robbin
                          wrote on 26 Aug 2011, 07:37 last edited by
                          #12

                          lol
                          try using "this":http://translate.google.com
                          :D

                          lukas gave you an example, you don't have "nameOfTheLayoutContainingTheButtons". He is just pointing out to you that you should use that method on the layout which CONTAINS YOUR BUTTONS.

                          1 Reply Last reply
                          0
                          • K Offline
                            K Offline
                            kalster
                            wrote on 26 Aug 2011, 07:40 last edited by
                            #13

                            i know that Eus. you read my message wrong which was just an example. i have tried ui->dockWidget->layout()->setSpacing(0); which is the name of the dock widget and it is not working.

                            1 Reply Last reply
                            0
                            • R Offline
                              R Offline
                              Robbin
                              wrote on 26 Aug 2011, 07:45 last edited by
                              #14

                              and that is what we all were saying - have you created a LAYOUT in that widget? I don't see QVBoxLayout, QHBoxLayout or QGroupBoxLayout in your ui code.

                              1 Reply Last reply
                              0
                              • K Offline
                                K Offline
                                kalster
                                wrote on 26 Aug 2011, 07:50 last edited by
                                #15

                                none of those layouts work. i have tried them before. the problem is that the textEdit horizontal width is a lot greater in width when i try these layout. it just does not work for me.

                                but i solved the problem. i should have had ui->dockWidgetContents instead of ui->dockWidget. this topic is solved. thank you everyone for the quick replies.

                                1 Reply Last reply
                                0
                                • E Offline
                                  E Offline
                                  Eddy
                                  wrote on 26 Aug 2011, 07:53 last edited by
                                  #16

                                  Glad you solved it.

                                  Could you add [solved] in front of your title?

                                  Qt Certified Specialist
                                  www.edalsolutions.be

                                  1 Reply Last reply
                                  0
                                  • K Offline
                                    K Offline
                                    kalster
                                    wrote on 26 Aug 2011, 07:57 last edited by
                                    #17

                                    i already did. thank you Eddy and Eus for trying so hard to help. :) also, thank you Lukas Geyer for leading me in the right direction.

                                    1 Reply Last reply
                                    0
                                    • R Offline
                                      R Offline
                                      Robbin
                                      wrote on 26 Aug 2011, 08:03 last edited by
                                      #18

                                      You're welcome :P

                                      1 Reply Last reply
                                      0

                                      4/18

                                      26 Aug 2011, 06:52

                                      topic:navigator.unread, 14
                                      • Login

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