Problems with Open-Source Downloads read https://www.qt.io/blog/problem-with-open-source-downloads and https://forum.qt.io/post/638946

Model view delegator



  • Hi everyone.
    I have created my own table model(QAbstractTableModel) and my delegator following the tutorial https://doc.qt.io/qt-5/modelview.html

    And it works fine except one thing. The first time my view shows the data from my model doesn't format the data because the delegator is not called. From my understanding the delegator is called when an item is edited. So, how could I displayed the data (as it is displayed when using delegator during edit role) the first time my view shows my data from the model?

    Thanks in advance



  • @medihech said in Model view dlegator:

    From my understanding the delegator is called when an item is edited.

    Nope, it's also called by the paintEvent of the view

    my model doesn't format the data because the delegator is not called

    This is not the reason why. You are looking in the wrong place

    So, how could I displayed the data (as it is displayed when using delegator during edit role)

    reimplement QStyledItemDelegate::displayText or, if it's not enough, QAbstractItemDelegate::paint



  • Thank you very much. The displayText works for me.


Log in to reply