Got error with QSplitterHandle

Gottfried Müller <[email protected]>
Newsgroups gmane.comp.python.pyqt-pykde
Message-ID <[email protected]>
I wanted to implement the qt example
https://doc.qt.io/qt-5/qsplitterhandle.html with PyQt5. And I've got an
error with my implementation:

TypeError: QSplitterHandle(Qt.Orientation, QSplitter): argument 1 has
unexpected type 'MySplitter'

Can anybody help? Here is the code of my implementation:

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# pylint: disable=missing-docstring

import sys

from PyQt5.QtWidgets import (
     QApplication, QWidget, QListView, QSplitter, QVBoxLayout,
QSplitterHandle
)
from PyQt5.QtCore import Qt


class MySplitterHandle(QSplitterHandle):

     def __init__(self, orientation, parent=None):
         super().__init__(parent)
         self.orientation(orientation)

     def paintEvent(self, event):
         print("do something")


class MySplitter(QSplitter):

     def __init__(self, orientation, parent=None):
         super().__init__(parent)
         self.setOrientation(orientation)

     def createHandle(self, orientation):
         return MySplitterHandle(orientation, self)


class ApplWindow(QWidget):

     def __init__(self, parent=None):
         super().__init__(parent)
         v01 = QListView(parent=self)
         v02 = QListView(parent=self)
         orientation = Qt.Vertical
         splitter = MySplitter(orientation, parent=self)
         splitter.createHandle(orientation)
         layout = QVBoxLayout()
         layout.addWidget(v01)
         layout.addWidget(splitter)
         layout.addWidget(v02)
         self.setLayout(layout)
         self.resize(400, 400)


def main():
     appl = QApplication(sys.argv)
     applWindow = ApplWindow()
     applWindow.show()
     return appl.exec_()


if __name__ == "__main__":
     main()

_______________________________________________
PyQt mailing list    [email protected]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.