[Solved] How to set font-family through stylesheet in QTextEdit



  • As mentioned in the title, I want to set the font-family of a QTextEdit with the use of a stylesheet.
    Setting the font size with:
    myTextEdit->setStyleSheet("QTextEdit {font-size: 12pt}");
    works as expected. But when I try to set the font-family with something like:
    myTextEdit->setStyleSheet("QTextEdit {font-family: "Droid Sans"}");
    nothing happens.

    Someone any ideas?



  • Mm, when I try the same thing on my Windows computer, it does work.
    setStyleSheet("font: 12pt "Times New Roman";");

    Are there differences when using stylesheets under Windows or Linux?

    UPDATE:
    Last night I found out that, while trying to set the font-family with a stylesheet in the TextEdit example does not work, is does work when I create a new project (which in fact is a remake of the TextEdit example).

    Does someone have an explanation for this?



  • Well, I still don't have an explanation for the behaviour as described above. But since I rebuild the project from scratch, I can set the necessary values through a stylsheet. So I will mark this question as solved...


Log in to reply
 

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