Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] remove the space in between the buttons
Qt 6.12 LTS is out! See what's new in the release blog

[SOLVED] remove the space in between the buttons

Scheduled Pinned Locked Moved General and Desktop
18 Posts 6 Posters 19.3k Views 1 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on 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 last edited by
      #5

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

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on 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
        • EddyE Offline
          EddyE Offline
          Eddy
          wrote on 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
          • ? Offline
            ? Offline
            A Former User
            wrote on 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
            • ? Offline
              ? Offline
              A Former User
              wrote on 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
              • ? Offline
                ? Offline
                A Former User
                wrote on 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
                • ? Offline
                  ? Offline
                  A Former User
                  wrote on 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
                  • ? Offline
                    ? Offline
                    A Former User
                    wrote on 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
                    • ? Offline
                      ? Offline
                      A Former User
                      wrote on 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
                      • ? Offline
                        ? Offline
                        A Former User
                        wrote on 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
                        • ? Offline
                          ? Offline
                          A Former User
                          wrote on 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
                          • EddyE Offline
                            EddyE Offline
                            Eddy
                            wrote on 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
                            • ? Offline
                              ? Offline
                              A Former User
                              wrote on 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
                              • ? Offline
                                ? Offline
                                A Former User
                                wrote on last edited by
                                #18

                                You're welcome :P

                                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
                                • Unsolved