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?
QtWS25 Last Chance

How can I rotate a QLabel in PyQt5?

Scheduled Pinned Locked Moved Unsolved Qt for Python
pythonqt for python
7 Posts 3 Posters 3.6k 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.
  • N Offline
    N Offline
    niklaspeter123
    wrote on 28 Dec 2021, 12:37 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!

    J 1 Reply Last reply 28 Dec 2021, 12:40
    0
    • N niklaspeter123
      28 Dec 2021, 12:37

      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!

      J Offline
      J Offline
      JonB
      wrote on 28 Dec 2021, 12:40 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
      • N Offline
        N Offline
        niklaspeter123
        wrote on 28 Dec 2021, 13:38 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!

        J 1 Reply Last reply 28 Dec 2021, 13:46
        0
        • N niklaspeter123
          28 Dec 2021, 13:38

          But

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

          Nevertheless many thanks!

          J Offline
          J Offline
          JonB
          wrote on 28 Dec 2021, 13:46 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
          • N Offline
            N Offline
            niklaspeter123
            wrote on 28 Dec 2021, 13:51 last edited by
            #5

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

            J 1 Reply Last reply 28 Dec 2021, 13:52
            0
            • N niklaspeter123
              28 Dec 2021, 13:51

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

              J Offline
              J Offline
              JonB
              wrote on 28 Dec 2021, 13:52 last edited by
              #6

              @niklaspeter123
              Sorry, "How" what?

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 28 Dec 2021, 19:56 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

                1/7

                28 Dec 2021, 12:37

                • Login

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