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

QTreeView branch drawing... missing branch?



  • Hey

    So I've run in to alittle bit of a hiccup...

    I'm using custom QStyledItemDelegate on my QTreeView, and I think it caused some issues...

    When I draw my items I'm missing alternativeBackgroundColors + vertical branch line without anything next to it...
    44253437-556f-47df-9bba-712efe42354c-image.png

    A standard QTreeView renders properly :
    9221096f-b47b-4607-b9d3-454038ace6e6-image.png

    I literally have no idea how to dig in to it... any hints? :- ))))

    TIA


    
    QTreeView::branch:has-siblings:!adjoins-item {
        background: white;
        border-image: none;
    	image: none;
    }
     
    QTreeView::branch:has-siblings:adjoins-item {
        background: white;
        border-image: none;
    	image: none;
    }
     
    QTreeView::branch:!has-children:!has-siblings:adjoins-item {
        background: white;
        border-image: none;
    	image: none;
    }
     
     
    QTreeView::branch:has-children:!has-siblings:closed,
    QTreeView::branch:closed:has-children:has-siblings {
        background: white;
        border-image: none;
    }
     
    QTreeView::branch:open:has-children:!has-siblings,
    QTreeView::branch:open:has-children:has-siblings  {
        background: white;
        border-image: none;
    }
    

    Running this code result in :

    e8dab571-c1be-4e25-901b-ba418ddb52a2-image.png

    I'm not getting any of the has-siblings:adjoins-item / etc items.


  • Lifetime Qt Champion

    Hi,

    A good starting point would be to share your delegate code. That way more eyes may spot what is going wrong.



  • @SGaist QStyledItemDelegate paints that branch? :O I never did any call to paint in in paint() function, how/where does it paint? o_O



  • @SGaist said in QTreeView branch drawing... missing branch?:

    Hi,

    A good starting point would be to share your delegate code. That way more eyes may spot what is going wrong.

    Hey

    Apology for the long delay. Had a wild run around the app hotfixing bunch of stuff...

    As far as I can tell adding this >

    QTreeView::branch {
        border-image: none 0;
        image: none 0;
    }
    

    Fixed the issue, no idea why :- ) Or what does the 0 at the end do...

    But it works :D - unless it breaks something else that I dont know about yet :D

    TIa


  • Lifetime Qt Champion

    In fact, it's the QTreeView::drawBranch that handles that.


Log in to reply