PDA

View Full Version : Updating Status Bar Icon



nbkhwjm
7th October 2008, 23:57
In the setup function of my application I have:


//Connection Status Icon
QLabel *test = new QLabel;
test->setPixmap(QPixmap(":/images/not_connected_32x32.png"));
test->setScaledContents(false);
//test->setFrameShadow(QFrame::Plain);
//test->setFrameShape(QFrame::NoFrame);
test->setAlignment(Qt::AlignRight);
ui.statusBar->insertPermanentWidget(0, test,0 );


This puts the correct Icon in the Status bar fine

My problem is updating it later, by function...

Here is what I have, but it is not working



void TestApp::updateStatusBarIcon(QString &statusIcon)
{
qDebug() << "Icon change" << statusIcon;
test1->setPixmap(QPixmap(statusIcon));
}

Any ideas how i can update the PIXMAP Icon on the statusBar?

TIA.

nbkhwjm
8th October 2008, 05:22
This seemed harder than it was. they key was to use QLabel in designer to create the LAbel with a Pixmap, then install it on the Status bar manually.

Once its there I could easily update it..

Example:

Install the icon on the status bar.


ui.statusBar->insertPermanentWidget(0, ui.statusIconLabel,0 );


Then Update it from the Connection Status function by:


ui.statusIconLabel->setPixmap(QPixmap(":/images/connected_32x32.png"));