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. Still having issues with Controlling the margin/Padding in a QGridLayout
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 3.9k 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.
  • musimbateM Offline
    musimbateM Offline
    musimbate
    wrote on last edited by
    #1

    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
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      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
      0
      • musimbateM Offline
        musimbateM Offline
        musimbate
        wrote on last edited by
        #3

        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
        0
        • musimbateM Offline
          musimbateM Offline
          musimbate
          wrote on last edited by
          #4

          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
          0

          • Login

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