Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to force repaint on QTreeView when using setIndexWidget()



  • Hey

    I'm having this issue ->

    2021_01_11---14-43-55_capture_1189.gif

    When I click, the selection does not appear "instantly" instead its being painted at "random". I'm left clicking, so the previous item should be deselected...

    The cause of it oculd be the fact that I use setIndexWidget() And I have a few QWidgets on each item that may conflict with some paiting logic...
    I was wondering if there is a way to set a repaint mode. I take now its "smart" and only repaints selected item - widget area, and skips the area outside the treeItem. Any way to set paint update methof on treeView from smart/partial to full tree repaint?

    TIA


  • Lifetime Qt Champion

    Hi
    How do you make the widgets be selected ?
    Some stylesheet ?
    setIndexWidget() floats the widgets on top of the cell so they normally dont react to cell being selected
    versus cell have focus.

    As far as I know, there is no repaint modes.



  • @mrjj As far as I remember, the widgets is to the right of the drop down/icon location of tree item. So I can see tree item underneath. I also made QWidget transparent using wa_transparent flag/option if I remember correctly. The are behind widget paints properly/updates. But the outer area where there is drop down icon/checkbox/icon is lagging. Its as if widgets took over the repain call & forgot to forward it to item that is replacing...


  • Lifetime Qt Champion

    Hi
    Not sure what is going on.
    Docs says autoFillBackground should be set to true as not to show both the cell and the widget floating above.
    The widget does not replace the item.

    https://doc.qt.io/qt-5/qabstractitemview.html#setIndexWidget

    So you used
    setAttribute(Qt::WA_TranslucentBackground); ?

    on the widgets ?



  • @mrjj Yup. I'll make a portable text example and post a code. Just need to get some spare time for it. brb


Log in to reply