PDA

View Full Version : Adding QLabel to QMainWindow statusbar



graciano
9th November 2013, 13:57
Hi
When adding QLabels to a QMainwindow e get this vertical lines separating them?
How do i remove it?
9771
Thanks

anda_skoa
9th November 2013, 14:41
One thing you could do is to put all things that should appear together into one widget and then add that widget to the status bar.

Cheers,
_

graciano
9th November 2013, 16:05
QLabel is already a Widget but anyway e tested it with the same result.
9772

Must be something else.

anda_skoa
9th November 2013, 16:48
Of course a QLabel is a QWidget, but that's not what I wrote.

But since you claim you have tested my suggestion, can you show the code of how you did it?

Cheers,
_

graciano
9th November 2013, 18:04
Please take a look: 9773

ChrisW67
10th November 2013, 04:05
The style puts separators between separate widgets in the status bar. If you do not want separators between your widgets in the status bar then only insert a single widget. You then have complete control over the layout of other widgets within that single widget. This is what anda_skoa suggested above, and you have not done in your code.



// You are doing the equivalent of this
QMainWindow a;
QStatusBar *sb = a.statusBar();
sb->addWidget(new QLabel("A"));
sb->addWidget(new QLabel("B"));
sb->addWidget(new QLabel("C"));
a.show();

// We are saying do this
QMainWindow b;
QStatusBar *sb = b.statusBar();
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(new QLabel("D"));
layout->addWidget(new QLabel("E"));
layout->addWidget(new QLabel("F"));
layout->setContentsMargins(0,0,0,0);
QWidget *container = new QWidget;
container->setLayout(layout);
sb->addWidget(container);
b.show();

graciano
10th November 2013, 11:01
I see ... didn't get it the first time.
Thanks