Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Still having issues with Controlling the margin/Padding in a QGridLayout

    General and Desktop
    2
    4
    3467
    Loading More Posts
    • 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.
    • musimbate
      musimbate last edited by

      Hi all,
      I am trying to stack a bunch of Toolbuttons inside a Widget so I can insert the widget in a toolbar.But I am getting margins or paddings that are not desired.I have tried setMargin on the Layout to no avail .Also I have tried to give the widget a fixed height and they unacceptably shrunk!Following is my code:
      @
      QAction * a = fileMenu->addAction("AAA");QToolButton * but1=new QToolButton(this);
      but1->addAction(a);

      QToolButton * but2=new QToolButton(this);
      but1->addAction(b);

      QToolButton * but3=new QToolButton(this);
      but1->addAction(c);

      QToolButton * but4=new QToolButton(this);
      but1->addAction(d);

      QGridLayout *mLayout=new QGridLayout(this);

      mLayout->addWidget(but1,0,0);
      mLayout->addWidget(but2,0,1);
      mLayout->addWidget(but3,1,0);
      mLayout->addWidget(but4,1,1);

      QWidget *mWidget=new QWidget(this);
      mWidget->setLayout(mLayout);

      ui->mainToolBar->insertWidget(a,mWidget);
      ui->mainToolBar->setMovable(false);@

      Any help would be appreciated.Thanks

      Why join the navy if you can be a pirate?-Steve Jobs

      1 Reply Last reply Reply Quote 0
      • raven-worx
        raven-worx Moderators last edited by

        did you try settings the "margins":http://qt-project.org/doc/qt-4.8/qlayout.html#getContentsMargins and "spacing":http://qt-project.org/doc/qt-4.8/qgridlayout.html#setSpacing the correct way?

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply Reply Quote 0
        • musimbate
          musimbate last edited by

          Thanks ravin-worx,I kind of had missed that.Setting the spacing solved my problem.

          Why join the navy if you can be a pirate?-Steve Jobs

          1 Reply Last reply Reply Quote 0
          • musimbate
            musimbate last edited by

            Hi guys,
            I have used the above code to build a toolbar but I am getting unwanted margins in my toolbar.The toolbar I am getting can be seen here": http://www.blikoon.com/?attachment_id=1537 .I want to get rid of the spaces in between .I have used setContentMargins and setSpacing and no luck so far.

            I am using Qt 4.8.1 and some of my google searches pointed out that this might be a bug in the Qt libraries.Does anybody know any workaround on this?It would really help.
            Thanks.

            Why join the navy if you can be a pirate?-Steve Jobs

            1 Reply Last reply Reply Quote 0
            • First post
              Last post