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. 2018 and still no solution for 90° rotated text labels with antialiasing?
Qt 6.11 is out! See what's new in the release blog

2018 and still no solution for 90° rotated text labels with antialiasing?

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 5 Posters 3.8k 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.
  • U Offline
    U Offline
    UrbanCee
    wrote on last edited by
    #1

    Is there still no easy way of rotating a QLabel containing text? I can use QPixmap, sure, but what about antialiasing? I know this has been asked before but that was during Qt 4.x, maybe in 5.10 there should be something convenient!

    Pablo J. RoginaP JKSHJ 2 Replies Last reply
    0
    • U UrbanCee

      Is there still no easy way of rotating a QLabel containing text? I can use QPixmap, sure, but what about antialiasing? I know this has been asked before but that was during Qt 4.x, maybe in 5.10 there should be something convenient!

      Pablo J. RoginaP Offline
      Pablo J. RoginaP Offline
      Pablo J. Rogina
      wrote on last edited by
      #2

      @UrbanCee do you know how this could be solved? Is there any code you can contribute to the Qt Project?

      Upvote the answer(s) that helped you solve the issue
      Use "Topic Tools" button to mark your post as Solved
      Add screenshots via postimage.org
      Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      1
      • U UrbanCee

        Is there still no easy way of rotating a QLabel containing text? I can use QPixmap, sure, but what about antialiasing? I know this has been asked before but that was during Qt 4.x, maybe in 5.10 there should be something convenient!

        JKSHJ Offline
        JKSHJ Offline
        JKSH
        Moderators
        wrote on last edited by
        #3

        @UrbanCee Will a QPainter do? https://stackoverflow.com/questions/17820428/how-to-rotate-text-for-drawtext

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        1 Reply Last reply
        1
        • U Offline
          U Offline
          UrbanCee
          wrote on last edited by
          #4

          So you mean subclassing QLabel and change Painter in there? Or is it possible to change the painter from a Widget from the outside?

          JKSHJ 1 Reply Last reply
          0
          • U UrbanCee

            So you mean subclassing QLabel and change Painter in there? Or is it possible to change the painter from a Widget from the outside?

            JKSHJ Offline
            JKSHJ Offline
            JKSH
            Moderators
            wrote on last edited by
            #5

            @UrbanCee said in 2018 and still no solution for 90° rotated text labels with antialiasing?:

            So you mean subclassing QLabel and change Painter in there? Or is it possible to change the painter from a Widget from the outside?

            Using QPainter involves subclassing a widget and reimplementing paintEvent().

            Note: I haven't tried this myself; this is just an idea. This approach will involve calculating the the coordinates and size of the text to be painted, using values of various QLabel properties.

            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

            1 Reply Last reply
            1
            • U Offline
              U Offline
              UrbanCee
              wrote on last edited by
              #6

              I C. I wanted to avoid that. Thought there would be an easier way.

              kshegunovK JKSHJ D 3 Replies Last reply
              0
              • U UrbanCee

                I C. I wanted to avoid that. Thought there would be an easier way.

                kshegunovK Offline
                kshegunovK Offline
                kshegunov
                Moderators
                wrote on last edited by
                #7

                In the development mailing list propose adding a transformation property that is applied automatically to the painter for the widgets when they paint their contents, see what people think and submit a suggestion/patch to the framework would be the way such a thing gets included. A user forum is the wrong place to request features.

                Read and abide by the Qt Code of Conduct

                1 Reply Last reply
                4
                • U UrbanCee

                  I C. I wanted to avoid that. Thought there would be an easier way.

                  JKSHJ Offline
                  JKSHJ Offline
                  JKSH
                  Moderators
                  wrote on last edited by
                  #8

                  @UrbanCee said in 2018 and still no solution for 90° rotated text labels with antialiasing?:

                  Thought there would be an easier way.

                  Not with QLabels, unfortunately. As @kshegunov said, make a feature request if you feel strongly about it.

                  You mentioned that the QPixmap workaround has antialiasing issues. A possible alternative is to use an SVG file with a QSvgWidget instead of QPixmap.

                  Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                  1 Reply Last reply
                  1
                  • U UrbanCee

                    I C. I wanted to avoid that. Thought there would be an easier way.

                    D Offline
                    D Offline
                    Devopia53
                    wrote on last edited by
                    #9

                    @UrbanCee

                    If the size of the QLabel is square and it only rotates 90/180/270 degrees, it can be simplified as follows.
                    Otherwise, as @JKSH said, you must calculate and process the changed size after rotation of the QLabel.

                    like this:

                    void MyLabel::initPainter(QPainter *painter) const
                    {
                        painter->translate(rect().center());
                        painter->rotate(90);
                        painter->translate(-rect().center());
                    }
                    
                    1 Reply Last reply
                    1

                    • Login

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