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]How to avoid Gap/Space between my custom widgets ?
Forum Updated to NodeBB v4.3 + New Features

[Solved]How to avoid Gap/Space between my custom widgets ?

Scheduled Pinned Locked Moved General and Desktop
25 Posts 8 Posters 9.6k 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.
  • C Offline
    C Offline
    Charles.qt
    wrote on 13 May 2012, 10:36 last edited by
    #1

    I have created a custom widget ,it contains Pushbutton at top ,down Qframe ,inside the frame some components like buttons,combobox,etc.
    !http://imageshack.us/photo/my-images/521/customwidget.jpg/(CustomWidget)!
    !http://imageshack.us/photo/my-images/833/accordionwidget.jpg/(AccordionWidget)!
    !http://imageshack.us/photo/my-images/140/accordionexample.jpg/(AccordionExample)!

    I placed my custom widget on AccordionWidget(Qwidget conatins QscrollArea),finally i am placing my AccordionWidget
    on MainWindow.

    What i required is
    !http://imageshack.us/photo/my-images/853/10316254.jpg/(Required Output)!

    Anyone can give me your suggestions.

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on 13 May 2012, 11:22 last edited by
      #2

      welcome to devnet

      You have managed to use the link button as explained in "this section":http://qt-project.org/wiki/ForumHelp#9bd9c32b79efb1b2d5b039e4d48300a9 described under 7. Since you have links to pictures you may want to use the picture described under 6.

      Please update your post. There is an edit shown below your avatar allowing you to update your post.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Charles.qt
        wrote on 13 May 2012, 11:59 last edited by
        #3

        ThankYou Koahnig, Plz reply my post.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          MuldeR
          wrote on 13 May 2012, 12:09 last edited by
          #4

          Insert a VerticalSpacer?

          http://img837.imageshack.us/img837/4971/vspacer.png

          My OpenSource software at: http://muldersoft.com/

          Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

          Go visit the coop: http://youtu.be/Jay...

          1 Reply Last reply
          0
          • Z Offline
            Z Offline
            Zlatomir
            wrote on 13 May 2012, 12:32 last edited by
            #5

            I can't see the picture, but i can assume you want to use "setContentsMargins":http://qt-project.org/doc/qt-4.8/qlayout.html#setContentsMargins or "setSpacing":http://qt-project.org/doc/qt-4.8/qlayout.html#spacing-prop or maybe both, hope it helps ;)

            https://forum.qt.io/category/41/romanian

            1 Reply Last reply
            0
            • C Offline
              C Offline
              Charles.qt
              wrote on 13 May 2012, 13:22 last edited by
              #6

              Guys Thanks for your reply

              @ MuldeR --> I dont want to avoid space on CustomWidget,I need to avoid space on AccordionExample between the section.

              !http://imageshack.us/photo/my-images/341/accordionexample.jpg/(AccordiaonExample)!

              How the panel2 and Panel3 is coming on RequiredOutput.jpg image which i gave the link on my previous post.

              1 Reply Last reply
              0
              • C Offline
                C Offline
                Charles.qt
                wrote on 14 May 2012, 06:26 last edited by
                #7

                Guys help me to solve this problem.

                1 Reply Last reply
                0
                • L Offline
                  L Offline
                  lgeyer
                  wrote on 14 May 2012, 10:18 last edited by
                  #8

                  Well, we can't see any of your linked pictures, so we are having quite a hard time of quessing what you are actually want to achieve.

                  1 Reply Last reply
                  0
                  • C Offline
                    C Offline
                    Charles.qt
                    wrote on 14 May 2012, 12:02 last edited by
                    #9

                    "Accordion Widget":http://imageshack.us/photo/my-images/833/accordionwidget.jpg/
                    "Accordion Example":http://imageshack.us/photo/my-images/140/accordionexample.jpg/
                    "Custom Widget":http://imageshack.us/photo/my-images/521/customwidget.jpg/

                    "Required Output":http://imageshack.us/photo/my-images/29/49828322.jpg/

                    To reduce Gap between the Custom Widgets ..
                    "Reduce Gap":http://imageshack.us/photo/my-images/341/accordionexample.jpg/

                    1 Reply Last reply
                    0
                    • W Offline
                      W Offline
                      Woody
                      wrote on 14 May 2012, 12:04 last edited by
                      #10

                      Place a vertical spacer above the first one and one below the last one?

                      File not found. Nobody leave the room!

                      1 Reply Last reply
                      0
                      • K Offline
                        K Offline
                        koahnig
                        wrote on 14 May 2012, 12:04 last edited by
                        #11

                        [quote author="sweeten" date="1336976796"]Guys help me to solve this problem.[/quote]

                        Somehow your pictures do not display. As far as I see, you have done it correctly.

                        For us it looks like this
                        !http://db.tt/KCdy7DMF(jpg-link)!

                        Vote the answer(s) that helped you to solve your issue(s)

                        1 Reply Last reply
                        0
                        • R Offline
                          R Offline
                          Rahul Das
                          wrote on 14 May 2012, 12:18 last edited by
                          #12

                          [quote author="Woody" date="1336997079"]Place a vertical spacer above the first one and one below the last one?[/quote]

                          I guess, one spacer would do. Also, if you are using vertical layout,set spacing to 0.For ex:

                          @ui->verticalLayout->setSpacing(0);@


                          Declaration of (Platform) independence.

                          1 Reply Last reply
                          0
                          • C Offline
                            C Offline
                            Charles.qt
                            wrote on 14 May 2012, 13:02 last edited by
                            #13

                            @ Rahul

                            I tried setSpacing, that doesn`t works...

                            1 Reply Last reply
                            0
                            • W Offline
                              W Offline
                              Woody
                              wrote on 14 May 2012, 13:13 last edited by
                              #14

                              Try adding a vertical spacer to you widget. It will set the space to a minimum.

                              File not found. Nobody leave the room!

                              1 Reply Last reply
                              0
                              • C Offline
                                C Offline
                                Charles.qt
                                wrote on 14 May 2012, 14:11 last edited by
                                #15

                                Woody
                                i am adding my custom widget through coding,

                                @ widget1 = new CustomWidget();
                                widget1->ui->pushButton->setText("SECTION 1");
                                widget2 = new CustomWidget();
                                widget2->ui->pushButton->setText("SECTION 2");
                                widget3 = new CustomWidget();
                                widget3->ui->pushButton->setText("SECTION 3");
                                widget4 = new CustomWidget();
                                widget4->ui->pushButton->setText("SECTION 4");@

                                How can i add Spacer to that? Thats why Rahul said to try setSpacing(),That also not works.

                                Thankyou for your information.

                                1 Reply Last reply
                                0
                                • W Offline
                                  W Offline
                                  Woody
                                  wrote on 14 May 2012, 14:25 last edited by
                                  #16

                                  Aah ok, sorry for the misunderstanding.

                                  Something like this: "QSpacerItem":http://qt-project.org/doc/qt-4.8/qspaceritem.html

                                  I didn't really looked into it. I'm using the graphical designer do achieve this.

                                  Hopes this works out for you.

                                  File not found. Nobody leave the room!

                                  1 Reply Last reply
                                  0
                                  • C Offline
                                    C Offline
                                    Charles.qt
                                    wrote on 15 May 2012, 06:58 last edited by
                                    #17

                                    Woody,

                                    I checked QSpacerItem,there is no need for using this class, spacing can be acheived by calling the method setSpacing().So i already tried setSpacing(),this also not works.

                                    1 Reply Last reply
                                    0
                                    • W Offline
                                      W Offline
                                      Woody
                                      wrote on 15 May 2012, 07:03 last edited by
                                      #18

                                      Mmh that is strange. You probably set a layout to the parent widget?

                                      Is it possible to provide the code, so I can have a better look?

                                      File not found. Nobody leave the room!

                                      1 Reply Last reply
                                      0
                                      • R Offline
                                        R Offline
                                        Rahul Das
                                        wrote on 15 May 2012, 07:23 last edited by
                                        #19

                                        Sweeten, Try the combination of spacer in VBoxLayout. It works.


                                        Declaration of (Platform) independence.

                                        1 Reply Last reply
                                        0
                                        • C Offline
                                          C Offline
                                          Charles.qt
                                          wrote on 15 May 2012, 08:24 last edited by
                                          #20

                                          I have uploaded my full project . Just run the application and see the Gap between the custom widgets(Section 1,Section 2,Section 3 & Section 4).

                                          Your suggestions are welcome.

                                          "Accordion Test":http://www.4shared.com/zip/rPHyPhdL/AccordionTest.html

                                          1 Reply Last reply
                                          0

                                          1/25

                                          13 May 2012, 10:36

                                          • Login

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