神刀安全网

IDAPython: migrating PySide code to PyQt5

Background

Contrary to previous versions that shipped with Qt 4.8.4, IDA 6.9 ships with Qt 5.4.1 and as we announcedsome time ago, this will force some changes for plugin writers who were using IDAPython + PySide in order to build custom interfaces.

What’s more, in addition to the Qt4 -> Qt5 switch, we have also chosen to drop PySide in favor of PyQt5, as it seems to be more actively developed.

Porting

While we were porting some internal plugins & test scripts, we have come across a number of ‘issues’ that are due both to the change in major Qt version, and also to the switch to PyQt5.

Here is a (non-exhaustive) list of such problems that needed to be dealt with.

Use ‘from PyQt5’ instead of ‘from PySide’

from PySide import QtCore, QtGui

Becomes:

from PyQt5 import QtCore, QtGui, QtWidgets

(notice the added ‘QtWidgets’. Keep reading.)

Most widgets are now in QtWidgets, not QtGui anymore (Qt5 architecture change)

from PySide import QtGui    edit = QtGui.QTextEdit()

Becomes:

from PyQt5 import QtWidgets    edit = QtWidgets.QTextEdit()

Converting TForm instances must be done to PyQt

from PySide import QtGui, QtCore    form = idaapi.find_tform("Output window")    w = idaapi.PluginForm.FormToPySideWidget(form)

Becomes:

from PyQt5 import QtGui, QtCore, QtWidgets    form = idaapi.find_tform("Output window")    w = idaapi.PluginForm.FormToPyQtWidget(form)

Public QEvent types are in QtCore.QEvent namespace

QtCore.QEvent.Type.XXX

Becomes:

QtCore.QEvent.XXX

Using QObject.connect() to connect signal with slot doesn’t work anymore. Use alternative approach.

obj.connect(query_action, QtCore.SIGNAL("triggered()"), self.ui.queryGraph)

Becomes:

query_action.triggered.connect(self.ui.queryGraph)

Final words

As I said above, this is a non-exhaustive list of issues we encountered. Should you encounter other issues, please let us know about them, so we can update & improve this page to help the community!

原文  http://www.hexblog.com/?p=975

转载本站任何文章请注明:转载至神刀安全网,谢谢神刀安全网 » IDAPython: migrating PySide code to PyQt5

分享到:更多 ()

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
分享按钮