PDA

View Full Version : Status Bar Empty



waynew
22nd November 2009, 01:07
When the oper value changes, I call MainWindow updateStats(oper) to display the new value. Problem is, nothing displays. I can see the status bar window, but nothing in it. The debug statement in updateStatus shows a good value for oper.



void MainWindow::updateStats(QString oper)
{
qDebug() << "IN updateStats with oper = " << oper;
QString output = tr("Current op is %1") .arg(oper);
mStatLabel->setText(output);
}


What could be wrong here?

wysota
22nd November 2009, 02:33
We cannot even see the status bar in your code. It's probably safe to assume that the label you use has been assigned to the status bar and given appropriate size. But then all would work, so there is a good chance this assumption is wrong.

waynew
22nd November 2009, 02:53
Sorry Wysota - I forget to include things in posts sometimes.
The status bar definition is like this:



MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
setupActions();

mStatLabel = new QLabel;
statusBar()->addPermanentWidget(mStatLabel);


I can't see what is wrong.

wysota
22nd November 2009, 09:19
Can you see the label at all in your status bar?

waynew
22nd November 2009, 12:55
Yes, I could definitely see the label. After some more testing, it appears that the status bar does display correctly when updateStats is called from within the main window, but not when it is called from another class. I can see with qDebug that it does get called with the correct parameter value from the other class, but the display does not change. Something to do with the way the main window event loop works?
I'm thinking it's time to change direction and try to make this work with a signal/slot.
Thanks for your patience.

wysota
22nd November 2009, 13:01
Main window doesn't have its own event loop. If the function is called, regardless of the caller, it should have the same effect. Maybe something else calls the method again and reverts the changes you made.

Try isolating the problem by trying to strip your code from everything unrelated until you reach a minimal compilable application reproducing the problem.