Re: Got error with QSplitterHandle

Gottfried Müller <[email protected]>
Newsgroups gmane.comp.python.pyqt-pykde
Message-ID <[email protected]>
Hi,

thanks also to Maurizio. Now it works fine. But there is a small
question again. Why  is "createHandle" in MySplitter called two times?

Gottfried

Here is my new 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.QtGui import QPainter
from PyQt5.QtCore import Qt


class MySplitterHandle(QSplitterHandle):

     def paintEvent(self, event):
         print("start paintEvent")
         painter = QPainter(self)
         painter.fillRect(event.rect(), Qt.blue)
         painter.end()


class MySplitter(QSplitter):

     def createHandle(self):
         print("creaMyHdl")
         return MySplitterHandle(self.orientation(), self)


class ApplWindow(QWidget):

     def __init__(self, parent=None):
         super().__init__(parent)
         v01 = QListView(parent=self)
         v02 = QListView(parent=self)
         #orientation = Qt.Vertical
         orientation = Qt.Horizontal
         splitter = MySplitter(orientation, parent=self)
         splitter.addWidget(v01)
         splitter.addWidget(v02)
         layout = QVBoxLayout()
         layout.addWidget(splitter)
         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.