Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Model view delegator
Forum Updated to NodeBB v4.3 + New Features

Model view delegator

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 294 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    medihech
    wrote on last edited by aha_1980
    #1

    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

    VRoninV 1 Reply Last reply
    0
    • M medihech

      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

      VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      @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

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      M 1 Reply Last reply
      3
      • VRoninV VRonin

        @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

        M Offline
        M Offline
        medihech
        wrote on last edited by
        #3

        Thank you very much. The displayText works for me.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved