Unsolved QTimeedit set color
-
Hi,
I want to set the font color for QTimeedit in source code(mainwindow.cpp) . Instead of setstylesheet function, is there any tool to set the font color in qtimeedit?. I tried QPalette class,but it was not work.
Can you help me to sort out this issues? -
Hi @SurendarK
QPalette *palette = new QPalette(); palette->setColor(QPalette::Text,Qt::red);//Here i change font color to red yourtimeedit->setPalette(*palette);
Hope this can help!
-
Hi
Small note.There is no reason to new the palette
QPalette palette;
...
yourtimeedit->setPalette(palette);Works just fine
The setPalette makes copy.
Also, with new you must then
delete palette;
to avoid to leak. -
@mrjj said in QTimeedit set color:
Hi
Small note.There is no reason to new the palette
QPalette palette;
...
yourtimeedit->setPalette(palette);Works just fine
The setPalette makes copy.
Also, with new you must then
delete palette;
to avoid to leak.Good point @mrjj ,
Delete palette was obvious for me , but you are right ,
QPalette palette;
Already does the job,
Thank you for your answer !