Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. How can I rotate a QLabel in PyQt5?
Forum Updated to NodeBB v4.3 + New Features

How can I rotate a QLabel in PyQt5?

Scheduled Pinned Locked Moved Unsolved Qt for Python
pythonqt for python
7 Posts 3 Posters 3.8k 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.
  • niklaspeter123N Offline
    niklaspeter123N Offline
    niklaspeter123
    wrote on last edited by
    #1

    I have a question! How can I rotate a QLabel in PyQt5?
    I already did it with

    .setStyleSheet('transform: rotate(90deg)')
    

    but that did nothing!

    JonBJ 1 Reply Last reply
    0
    • niklaspeter123N niklaspeter123

      I have a question! How can I rotate a QLabel in PyQt5?
      I already did it with

      .setStyleSheet('transform: rotate(90deg)')
      

      but that did nothing!

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @niklaspeter123
      You are being optimistic thinking QSS will accept that CSS --- it won't!.

      See e.g. https://stackoverflow.com/questions/19489999/qlabel-rotation. I believe you can rotate its pixmap but not its text.

      1 Reply Last reply
      0
      • niklaspeter123N Offline
        niklaspeter123N Offline
        niklaspeter123
        wrote on last edited by
        #3

        But

        1. It's C++ and not Python!
        2. How can i put a label into a QPixmap?

        Nevertheless many thanks!

        JonBJ 1 Reply Last reply
        0
        • niklaspeter123N niklaspeter123

          But

          1. It's C++ and not Python!
          2. How can i put a label into a QPixmap?

          Nevertheless many thanks!

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @niklaspeter123
          Most examples for Qt are in C++. If you can find a Python example that's fine. Otherwise you have to translate from C++ to Python, which I don't think is very hard.

          You cannot put a QLabel onto a QPixmap. You can put a QPixmap onto a QLabel.

          1 Reply Last reply
          0
          • niklaspeter123N Offline
            niklaspeter123N Offline
            niklaspeter123
            wrote on last edited by
            #5

            How? If it wasn't so difficult to translate from C++ to Python?

            JonBJ 1 Reply Last reply
            0
            • niklaspeter123N niklaspeter123

              How? If it wasn't so difficult to translate from C++ to Python?

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by
              #6

              @niklaspeter123
              Sorry, "How" what?

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Hi,

                Load your picture in a QImage, rotate it and the make a QPixmap out of it before setting it on your QLabel.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                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