Adding QStatusBox to form - no show ?
-
Part of the attached code is to add QStatusBar to the class / form .
statusBar->showMessage does not "show" as expected.
The test added
statusLabel->setText("TEST Status Label");
statusProgressBar->setTextVisible(true);works as expected
Default QStatusBox works as expected in main window .
Like to have same - QStatusBox object added to each of derived dialog form.**QUESTION
What is missing in implementing in form / dialog **
statusBar->showMessage ??Partial test code
MDiChild_Form_BT::MDiChild_Form_BT(QWidget *parent) : QWidget(parent), ui(new Ui::MDiChild_Form_BT) { ui->setupUi(this); // create objects for the label and progress bar statusLabel = new QLabel(this); works fine , text shows at the top of form // statusProgressBar = new QProgressBar(this); works fine with default value in the form statusBar = new QStatusBar(this); statusBar ->show(); statusBar->visibleRegion(); statusBar->showMessage("TEST status bar message ",100000); time makes no difference statusBar ->show(); #ifdef BYPASS statusBar = new QStatusBar(this); statusBar->showMessage("TEST status bar message "); statusBar ->show(); #endif statusLabel->setText("TEST Status Label"); #ifdef BYPASS // set text for the label statusLabel->setText("Status Label"); // make progress bar text invisible statusProgressBar->setTextVisible(true); #endif // add the two controls to the status bar // ui->statusBar->addPermanentWidget(statusLabel); // ui->statusBar->addPermanentWidget(statusProgressBar,1); // QStatusBar *SB = new QStatusBar(); // "Status bar text "); // SB->show(); // SB->showMessage("TESTS status bar messge "); // statusBar()->showMessage("TEST status bar text "); // showMessage(const QString & message, int timeout = 0) // ui->statusBar->showMessage("Status"); // When the action triggered, set the progress bar at 51% // statusProgressBar->setValue(51); // createStatusBar(); // statusBar()->currentMessage("Test status bar curent message "); // statusBar()->showMessage(tr("Ready")); }
MDiChild_Form_BT::MDiChild_Form_BT(QWidget *parent) :
QWidget(parent),
ui(new Ui::MDiChild_Form_BT)
{
ui->setupUi(this);
// create objects for the label and progress bar
// statusLabel = new QLabel(this);
// statusProgressBar = new QProgressBar(this);
statusBar = new QStatusBar(this);
statusBar ->show();
statusBar->visibleRegion();
statusBar->showMessage("TEST status bar message ",100000);
statusBar ->show();```......................
Will appreciate suggestion towards solution, commentary on my test code style ARE unnecessary to solve the issue.
-
@AnneRanch
Usually StatusBar is part of QMainWindow.But you can add one to a layout:
auto statusBar=new QStatusBar; auto progressBar=new QProgressBar; statusBar->addPermanentWidget(progressBar); statusBar->showMessage("Hello"); layout->addWidget(statusBar);