Font characteristic on GUI



  • Hi,

    While I am making a GUI, by writing information on a label, I find that there few things to change about font: size, family, bold, italic, etc. (I am using Qt Designer.) I cannot change the color of font. There is neither option like shadow (like what we can do in MS Office), etc.

    How can I make these? Could anyone tell me please? Thanks!


  • Moderators

    shadows are not implemented in QFont right now... and i don't know if there are plans that it will be.

    You can change the text color only on the QWidget not on the QFont itself:
    @
    QPalette palette = widget->palette();
    palette.setColor( QPalette::Text, Qt::red );
    widget->setPalette( palette );
    @
    or use
    @
    widget->setStyleSheet("color: red;");
    @



  • Thanks for the reply. So now in Qt the text style can only be modified in terms of size, family type, bold, and color? Impossible to have some cool effects?

    Does anyone has an idea please?


  • Moderators

    you can do all the text transformations QFont provides.

    It depends if you draw your text yourself? If so you can paint all effects your self. Drop shadow for example you could implement with the same text drawn blurred and translated by some pixels.



  • Hi dekeenfrance,
    Did you try use richtext, like this

    @label.setText("<font color='red'>label text</font>");@

    Hope it's util.
    Regards


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.