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. [resolved] How to display a string in different font size

[resolved] How to display a string in different font size

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 731 Views
  • 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.
  • S Offline
    S Offline
    stuartx
    wrote on last edited by stuartx
    #1

    Hi, I want to display a string in QGraphicsScene in different font size, eg. "100mph". I can achieve that by putting each piece in a different string. For simplicity, is there any way to display it in a single string?

    Thanks.

    p3c0P 1 Reply Last reply
    0
    • S stuartx

      Hi, I want to display a string in QGraphicsScene in different font size, eg. "100mph". I can achieve that by putting each piece in a different string. For simplicity, is there any way to display it in a single string?

      Thanks.

      p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi @stuartx,
      You can use QGraphicsTextItem and add it to QGraphicsScene. It has setHtml wherein you can set the text in HTML format way. So,

      QGraphicsTextItem *txt = new QGraphicsTextItem;
      txt->setHtml("<font size=\"6\">100</font><I>mph</I>");
      
      scene->addItem(txt);
      

      157

      1 Reply Last reply
      0
      • S Offline
        S Offline
        stuartx
        wrote on last edited by stuartx
        #3

        Hi p3c0, Thank you very much. Your method works well.

        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