qt - How to get colored transient messages in QStatusBar? -
i need color-code messages flashing in status bar of qt5.5 app.
i using showmessage this:
ui->statusbar->showmessage("my message", 5000); i change color of single message. i've found no way short of subclassing qstatusbar , overriding showmessage(). need such invasive change?
i tried use rich text along lines of:
ui->statusbar->showmessage(qstring("<html><head/><body><p style=\"color:red\">%1</p></body></html>").arg("my message")); but doesn't seem recognized (prints tags).
altering palette or setting style-sheet not limited current message.
what else try?
how colored transient messages in qstatusbar?
altering palette or setting style-sheet not limited current message.
altering stylesheet not apply widgets in program. can limit scope of stylesheet.
#include "mainwindow.h" #include "ui_mainwindow.h" #include <qtimer> mainwindow::mainwindow(qwidget *parent) : qmainwindow(parent), ui(new ui::mainwindow) { ui->setupui(this); // stylesheet can applied within ui->statusbar hierarchy of // objects, can make more narrow scope // ui->statusbar->setstylesheet("qstatusbar{color:red}") if needed ui->statusbar->setstylesheet("color: red"); ui->statusbar->showmessage("text!"); qtimer::singleshot(2000, this, slot(tryanothercolor())); } void mainwindow::tryanothercolor() { ui->statusbar->setstylesheet("color: blue"); ui->statusbar->showmessage("more text!"); } i tried use rich text
my guess not qt widget controls have rich-text rendering functionality understand css-like stylesheets..
Comments
Post a Comment