Qt.py icon indicating copy to clipboard operation
Qt.py copied to clipboard

Conversion guide

Open mottosso opened this issue 8 years ago • 5 comments

Converting a project initially developed wih PyQt4, PyQt5 or PySide should be relatively straightforward and similar across projects. Let's collect our thoughts on some of the things to consider when heading down this route.


#### From PySide2

Qt.py conforms to the interface of PySide2, so if your code is already written for that you should only ever need to:

  1. Search-and-replace PySide2 with Qt and you're done.

From PySide

This should be relatively straightforward as well.

  1. Replace references to QtGui with QtWidgets apart from a few exceptions.

From PyQt5

Here I'd imagine:

  1. Look into the different names for signals and properties, e.g. pyqtSignal

From PyQt4

Prepend this to the steps outlined for PyQt5

  1. Convert code via pyqt4topyqt5

Finally, look towards CAVEATS.md for details and workarounds.


### What else?

What's missing? Let's fill in the blanks.

mottosso avatar Aug 12 '16 11:08 mottosso

Hm. Wasn't something moved to/from QtCore in Qt5... I can't remember right now.

fredrikaverpil avatar Aug 12 '16 12:08 fredrikaverpil

Some additional material for reference.

  • https://wiki.qt.io/Transition_from_Qt_4.x_to_Qt5

Maybe that's the way to go? To populate a list of links to existing links? The Qt Company is likely on the same mission for their own sake.

mottosso avatar Aug 26 '16 12:08 mottosso

This is a huge issue.

Let's make it less frightening, how about an example of something you currently have or have mocked up specifically for this guide of a typical project importing PySide and using QWidget and friends from QtGui along with qApp and how you can transition these to Qt.py and enter the land of Qt 5?

Just enough to give the reader the most basic idea of the work that lies ahead.

# Example
import sys
from PySide import QtGui

self = sys.modules[__name__]
self.active_window = None

class Window(QtGui.QDialog):
  def __init__(self, parent=None):
    super(Window, self).__init__(parent)

def show():
  try:
    self.active_window.deleteLater()
  except:
    pass

  window = Window()
  window.show()

  self.active_window = window

mottosso avatar May 04 '17 17:05 mottosso

How about extending lib2to3 in python standard library ( add some custom fixers) to make the conversion ?

oglops avatar Jul 07 '17 16:07 oglops

Sounds interesting, you're welcome to give it a shot.

mottosso avatar Jul 07 '17 16:07 mottosso