Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QLabel embedding in QStatusBar using Qt Designer

Is there any solution to embed a QLabel in QStatusBar using Qt Designer?

like image 495
Mohammad Sheykholeslam Avatar asked Apr 26 '10 06:04

Mohammad Sheykholeslam


3 Answers

I don't believe so. It's fairly simple to add one programmatically, though.

If you're just wanting to show a message, you could use: statusBar()->showMessage(tr("Message Here"));, or alternatively if you really needed a QLabel on the status bar, you could do something along the lines of:

QLabel *label = new QLabel("Message");
statusBar()->addWidget(label);

label would become a child of statusBar(), and appear in the first empty spot from the bottom left (addPermanentWidget(label) would add it to the first empty spot from the bottom right). If you place QLabel label in the classes header (or other var name), you'd be able to access the variable directly later (removing the initial QLabel type from the first line, of course).

like image 126
Kitsune Avatar answered Oct 22 '22 16:10

Kitsune


It is not possible with Qt Designer. I resolve it by creating label a in Qt Designer and later in constructor of my MainWindows add this line:

Ui::"class name of my MainWindows"::"name of statusBar Object"->addWidget("Object Name of Label");

In my application, the class name of mainwindows is MainWindowsForm, the status bar is named statusBar and the label is named informationLabel. Then I have:

Ui::MainWindowsForm::statusBar->addWidget(informationLabel);
like image 41
Joshwa Avatar answered Oct 22 '22 14:10

Joshwa


It's not possible even if you would manually edit UI file.

like image 5
delor Avatar answered Oct 22 '22 15:10

delor