Line crossing widgets



  • Hello all,

    Here is my issue. I have a QTreeWidget with widgets as children something like this :

    |>Parent
    Child Widget1
    Child Widget2
    Child Widget3

    |>Parent2
    Child Widget1
    Child Widget2
    Child Widget3

    etc, ... These children widgets contain some graphics like a rectangle (XXXXXX here)

    so, it looks like that :

    |>Parent
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    |>Parent2
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    I need a vertical line to cross all this TreeWidget and the children widgets, something like that :

    |>Parent
    XXXXXXXXXXXX | XXXXXXXXXXXXXXXXXXXXXXX
    XXXXXXXXXXXX | XXXXXXXXXXXXXXXXXXXXXXX
    XXXXXXXXXXXX | XXXXXXXXXXXXXXXXXXXXXXX

    |>Parent2
    XXXXXXXXXXXX | XXXXXXXXXXXXXXXXXXXXXXX
    XXXXXXXXXXXX | XXXXXXXXXXXXXXXXXXXXXXX
    XXXXXXXXXXXX | XXXXXXXXXXXXXXXXXXXXXXX

    I have no idea how to achieve that. Does anybody have an idea? That would be very helpful.
    Cheers,



  • Hmmm,

    seems like You will need to subclass "QItemDelegate":http://qt-project.org/doc/qt-4.8/qitemdelegate.html to achieve this. Here You have an example how to sublass and use it: "Star delegate example.":http://harmattan-dev.nokia.com/docs/platform-api-reference/xml/daily-docs/libqt4/itemviews-stardelegate.html .

    Maybe You will also need to show Your children data in 2 columns? To achieve this Your model's "columnCount":http://qt-project.org/doc/qt-5.0/qtcore/qabstractitemmodel.html#columnCount should return 2 and Your "data":http://qt-project.org/doc/qt-5.0/qtcore/ qabstractitemmodel.html#data method should return proper content.

    I hope this will help. In case of any doubts just ask here :).

    Robert



  • Hello Bob,
    Thannks for your help.
    I dont want to split the widget, I just want to draw a QGraphicsItem (here the line) on the widget.
    I was able to draw a simple QlineF line on the widget by reimplementing paintEvent() on the widget but this doesn't look to work for a QGraphicsItem...



  • Hmmm,

    can You place here a little example code what You are trying to do?

    Robert


Log in to reply
 

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