QPainter: Assemble parts of a widget.



  • I've been looking into owner draw painting, using QPainter.

    My basic understanding runs as far as in "this tutorial here.":http://blog.rburchell.com/2010/02/pyside-tutorial-custom-widget-painting.html

    Along with the regular class references.

    The task being, creating a custom widget that uses bits of another one.

    Currently my goal is to draw a widget using the background theme represented inside a table view header.

    This corresponds with my previous post, editing a tableviews header labels.

    I've seen notes using a QStylepainter, but no tutorials for that particular option.

    Any ideas/examples are appreciated, thank you. :)

    @

    --: Import the required modules:

    from PySide.QtGui import * # QT widget library

    class Key(QWidget):

    --------------

    On creation do

    --------------

    def init(self, parent):

    Init the parent constructor:

    QWidget.init(self, parent)

    --------------------------------------

    When the widget requires a repaint do:

    --------------------------------------

    def paintEvent(self, ev):

    this = QPainter( self)

    ..

    if name == 'main':
    import sys; app = QApplication(sys.argv)
    window = QWidget(None)
    widget = Key(window)
    window.show()
    app.exec_()
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.