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. Need some help migrating code from PySide2 to PySide6 (SideFX decided to update)
Forum Updated to NodeBB v4.3 + New Features

Need some help migrating code from PySide2 to PySide6 (SideFX decided to update)

Scheduled Pinned Locked Moved Solved Qt for Python
5 Posts 2 Posters 766 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.
  • A Offline
    A Offline
    Adam Ferestad
    wrote last edited by
    #1

    Hello all,

    SideFX has decided to update Houdini to PySide6 from PySide2 and, predictably, it has broken some of the front end code that the tools my company builds. For reference, I am not a Qt expert by any means, but I am well versed in basically everything else Python. I am also not the original author of this code, but I need to figure out how to create the same effect in PySide6. The root of the issue is that QApplication.desktop() has been removed. Here is the (currently) offending code:

    def center(base_instance):
        """
        Center the GUI in the screen, so that it doesn't show up in the top left or off-screen when the window is launched.
        """
        geo = base_instance.geometry()
        screen = QtWidgets.QApplication.desktop().screenNumber(QtWidgets.QApplication.desktop().cursor().pos())
        centerPoint = QtWidgets.QApplication.desktop().screenGeometry(screen).center()
        geo.moveCenter(centerPoint)
    
        base_instance.setGeometry(geo)
    

    I have looked at QtGui.QScreen as the Qt Changes page says is supposed to be the replacement, but I cannot find any of the functionality that is used here. There is nothing for checking the cursor position. I do not see where to select which screen is the target. I am seeing that once I get there I can change the centerPoint = line to use QScreen.AvailableGeometry.center(), but the screen selection bit is being arcane right now.

    I am hoping that I don't run into too many more errors like this, but I think that getting the answer here might help me clear up future errors.

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

      Hi and welcome to devnet,

      I think you are looking for QGuiApplication.screenAt. QApplication is a subclass so you can directly use it with it.

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

      A 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi and welcome to devnet,

        I think you are looking for QGuiApplication.screenAt. QApplication is a subclass so you can directly use it with it.

        A Offline
        A Offline
        Adam Ferestad
        wrote last edited by
        #3

        @SGaist said in Need some help migrating code from PySide2 to PySide6 (SideFX decided to update):

        Hi and welcome to devnet,

        I think you are looking for QGuiApplication.screenAt. QApplication is a subclass so you can directly use it with it.

        Thanks for the advice, I will go give it a look to see what I can do with this. Thanks for the suggestion.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          Adam Ferestad
          wrote last edited by
          #4

          @SGaist that got me there, thank you.

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

            Excellent !

            Then please mark the thread as solved using the "Topic Tools" button or the three dotted menu beside the answer you deem correct so other forum users may know a solution has been found :-)

            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
            • A Adam Ferestad has marked this topic as solved

            • Login

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