Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] How to set font-family through stylesheet in QTextEdit
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
3 Posts 1 Posters 18.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jan-Willem
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    1
    • J Offline
      J Offline
      Jan-Willem
      wrote on last edited by
      #2

      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?

      1 Reply Last reply
      0
      • J Offline
        J Offline
        Jan-Willem
        wrote on last edited by
        #3

        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...

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved