How to add stretchable spacer in Qtoolbar?

后端 未结 1 1534
长情又很酷
长情又很酷 2021-02-05 05:46

I want some of my toolbar actions appear left-bound and some right-bound. I Gtk I remember adding a stretchable (expandable) separator. How do I achieve that in Qt?

I u

1条回答
  •  滥情空心
    2021-02-05 06:26

    You can use an empty widget with automatic expanding, it works like the spacers you can use in Qt Designer:

    tb = my_toolbar;
    
    QWidget* empty = new QWidget();
    empty->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
    tb->addWidget(empty);
    
    tb->addWidget(otherWidget);
    

    0 讨论(0)
提交回复
热议问题