How to change the font and color of entire Qt application at runtime?
Hi
I am building a desktop application using Qt4. I have multiple forms and multiple types of widgets on those forms. Now i have a requirement to allow the user to change the color and font of entire application at run-time ( without restarting the application). I am really not sure how to achieve this. please suggest.
Re: How to change the font and color of entire Qt application at runtime?
void QApplication::setFont ( const QFont & font, const char * className = 0 ) [static]
set to the qpplication of your font .. try this one ... but not sure ..
Re: How to change the font and color of entire Qt application at runtime?
hey it didnt worked...what i did is..i took one ui..and added one lable and pushbutton to it.
On click of pushbutton i activated a slot "test()" in which i called QApplication::setFont().
but it only chnages the color of pushButton not the entire form.
my code is here:
ColorMode::ColorMode(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
connect(ui.pushButton, SIGNAL(clicked()),this, SLOT(test()));
}
void ColorMode::test()
{
QFont font("Times", 15, QFont::Bold);
QApplication::setFont(font);
}
any suggestions???
Re: How to change the font and color of entire Qt application at runtime?
Can you check that you slot is being called or not. Because this should work.;);):cool:
Re: How to change the font and color of entire Qt application at runtime?
hey..it checked..the slot is getting called for sure but its only changing the font of pushButton not for the label.
Re: How to change the font and color of entire Qt application at runtime?
Can you add more test buttons to your UI. So we can find out whats wrong with QLabel. Why only label's font is not getting changed.
Re: How to change the font and color of entire Qt application at runtime?
Assumably, the label is not being updated because it is not being redrawn. Try, the updateAllWidgets function shown at QApplication::allWidgets