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
Servers for Qt installer are currently down

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

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 738 Views 2 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.
  • S Offline
    S Offline
    stuartx
    wrote on 25 May 2015, 05:32 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.

    P 1 Reply Last reply 25 May 2015, 06:31
    0
    • S stuartx
      25 May 2015, 05:32

      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.

      P Offline
      P Offline
      p3c0
      Moderators
      wrote on 25 May 2015, 06:31 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 27 May 2015, 15:03 last edited by stuartx
        #3

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

        1 Reply Last reply
        0

        1/3

        25 May 2015, 05:32

        • Login

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