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



  • 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


  • Moderators



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



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.