Important: Please read the Qt Code of Conduct -

Grid View : draw outside of delagate limits

  • Hi every one, I have some items displayed in a GridView. In those items, I have a text that might be long so I'm using the elide option on it. The thing is I would like to have a tooltip that popup with the full text.
    I managed to do almost everything (tooltip works fine and pop up with the text, ...) except for one thing : when the tooltip is too wide (which is often the case because I'm using it to display long text), a part of it is displayed under the cell on the right.
    That totally makes sens as everything inside the cell N is drawn before the cell N+1 so it's z-index is lower but I would like to know if there is a way to force a specific QML element to be drawn above every other (or at least above my whole GridView).

    ps : I prefer not to use z-index to do so as I have absolutely no idea how many elements I may have in the GridView so I would like to avoid setting it to 1000 for example and then having some issues when you have more than 1000 layers drawn. But if you have an idea using z-index that doesn't have this problem, I'm totally fine with it.


  • Qt Champions 2018

    The solution would be to have an element that is above all delegates, and preferably above everything else.

    Something that would work is an Item parented to the Window's contentItem with a high z value that you can display on demand and position on your delegate.
    Hopefully there are existing components that do that : QQC2 Popup does the first part, and the rest is done by QQC2 Tooltip (a specialized Popup).

  • Ok thx, i've also found a very detailed solution on stackoverflow on how to use a parent above evrything to display a component on top.
    I didn't know about the ToolTip component. i might endup using it since it has the same purpose as what I did but probably more efficient and more weird-case-proof. So thank you for your answser.