W
W
WayMax2017-05-11 14:09:58
Qt
WayMax, 2017-05-11 14:09:58

How to add items to QStatusBar?

Found on the Internet only option:

QLabel *label1;
label1 = new QLabel();
ui->statusBar->addWidget(label1); // в левой части статусбара

QLabel *label2;
label2 = new QLabel();
ui->statusBar->addPermanentWidget(label2); // в правой части статусбара

But it turns out "mixing" of code and graphics. Is it possible to add these 2 labels in design mode?
If you can't, and you have to add it like this, is it possible to replace #include QLabel with something more "universal"?
For example, if I want to add more and ProgressBar, I will have to add #include QProgressBar, I thought it would be possible to write something like #include QWindow or #include QWidget, but no.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mercury13, 2017-05-11
@WayMax

1. Similar roughness in Qt wagon and small cart. I don't know about the status bar, but toolbars (if they don't consist of buttons alone, or if there are a lot of them on one form) have to be assembled programmatically.
2. You can't. We need a constructor of a specific type - QLabel, which means we need a header where this constructor is.
3. Understand that even if the form editor is perfect, as in Embarcadero, there are tasks that it does not perform. This can be tricky behavior when resizing the form, requests to the components “wait to update me” and “everything, now you can”, appearance settings and much, much more ... Separation of code and graphics should be done by separating into another module of the working code, and not by separating graphics to *.ui (or *.dfm) file.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question