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 position Text in a QGraphicsScene
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] how to position Text in a QGraphicsScene

Scheduled Pinned Locked Moved General and Desktop
qgraphicsscene
8 Posts 4 Posters 18.7k Views 3 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.
  • youzkingY Offline
    youzkingY Offline
    youzking
    wrote on last edited by youzking
    #1

    the method addText(const QString & text, const QFont & font = QFont()) of the QGraphicsScene does not offer a way to position the inserted text ,

    how can i insert a text in a desired position ?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mcosta
      wrote on last edited by
      #2

      Hi,

      you can use the setPos() function.

      QGraphicsTextItem *text = scene->addText("Hello World");
      text->setPos(100, 200);
      

      Once your problem is solved don't forget to:

      • Mark the thread as SOLVED using the Topic Tool menu
      • Vote up the answer(s) that helped you to solve the issue

      You can embed images using (http://imgur.com/) or (http://postimage.org/)

      youzkingY 1 Reply Last reply
      2
      • M mcosta

        Hi,

        you can use the setPos() function.

        QGraphicsTextItem *text = scene->addText("Hello World");
        text->setPos(100, 200);
        
        youzkingY Offline
        youzkingY Offline
        youzking
        wrote on last edited by
        #3

        @mcosta

        okkk !!
        that's what m searching for ^^
        thank you , !!

        M 1 Reply Last reply
        0
        • youzkingY youzking

          @mcosta

          okkk !!
          that's what m searching for ^^
          thank you , !!

          M Offline
          M Offline
          mcosta
          wrote on last edited by
          #4

          @youzking said:

          thank you , !!

          You're welcome.

          When the problem is solved, you should do:

          1. Mark the post as SOLVED (helps when someone is looking for a solution for a problem)
          2. Vote the best answers you received (optional but helps to find which answers really contributed to the solution)

          Once your problem is solved don't forget to:

          • Mark the thread as SOLVED using the Topic Tool menu
          • Vote up the answer(s) that helped you to solve the issue

          You can embed images using (http://imgur.com/) or (http://postimage.org/)

          youzkingY 2 Replies Last reply
          3
          • M mcosta

            @youzking said:

            thank you , !!

            You're welcome.

            When the problem is solved, you should do:

            1. Mark the post as SOLVED (helps when someone is looking for a solution for a problem)
            2. Vote the best answers you received (optional but helps to find which answers really contributed to the solution)
            youzkingY Offline
            youzkingY Offline
            youzking
            wrote on last edited by
            #5

            @mcosta

            yes i know and i wanted to do so ,
            but i can't find how to do it (or it is not clear), so i thought that the forum does not offer this option !!

            1 Reply Last reply
            0
            • M mcosta

              @youzking said:

              thank you , !!

              You're welcome.

              When the problem is solved, you should do:

              1. Mark the post as SOLVED (helps when someone is looking for a solution for a problem)
              2. Vote the best answers you received (optional but helps to find which answers really contributed to the solution)
              youzkingY Offline
              youzkingY Offline
              youzking
              wrote on last edited by
              #6

              @mcosta

              aah , i have just to rename the thread title ,, ok

              1 Reply Last reply
              0
              • B Offline
                B Offline
                bjakubb
                wrote on last edited by
                #7

                Can you show me how to use this in Pyqt5 please?

                G 1 Reply Last reply
                0
                • B bjakubb

                  Can you show me how to use this in Pyqt5 please?

                  G Offline
                  G Offline
                  Guaramango
                  wrote on last edited by
                  #8

                  @bjakubb
                  text = self.scene.addText('Hello world')
                  text.setPos(150, 200)

                  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