Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [Solved] Invidual itemDelegate for each column of table\listview
Forum Updated to NodeBB v4.3 + New Features

[Solved] Invidual itemDelegate for each column of table\listview

Scheduled Pinned Locked Moved QML and Qt Quick
23 Posts 2 Posters 9.0k Views 2 Watching
  • 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.
  • I illunara
    2 Nov 2015, 05:59

    @p3c0 Sorry for confuse you, but just focus on this

     ModelAbstract* model = static_cast<ModelAbstract*>(index.internalPointer());
     qDebug() << model->getData("ItemType");
    

    What i meant here is, the index of styleData.value given in tableviewColumn is wrong. Since the output value is same one item.
    And here is the definition of getData(QString dataname)

    virtual QVariant    getData(QString dataname) const;
    QVariant    Project::getData(QString dataname) const {
    if(dataname == "ItemDisplayName") {
        QVariantMap returnData;
        returnData["ItemDisplayName"] = m_name;
        returnData["ItemType"] = m_type;
        return returnData;
    } else if(dataname == "ItemType")
        return "Project";
    else return QVariant();
    }
    

    I also have a Q_INVOKABLE getData(QString dataname) inside QAbstractItemModel class,

    P Offline
    P Offline
    p3c0
    Moderators
    wrote on 2 Nov 2015, 06:23 last edited by
    #21

    @illunara According to your earlier code:

    QVariantMap TreeViewDataModel::get(QModelIndex index) {
    ModelAbstract* model = static_cast<ModelAbstract*>(index.internalPointer());
    qDebug() << model->getData("ItemType");
    return QVariantMap();
    

    You are fetching data for "ItemType". And now the definition of getData:

    virtual QVariant    getData(QString dataname) const;
    QVariant    Project::getData(QString dataname) const {
    if(dataname == "ItemDisplayName") {
        QVariantMap returnData;
        returnData["ItemDisplayName"] = m_name;
        returnData["ItemType"] = m_type;
        return returnData;
    } else if(dataname == "ItemType")
        return "Project";
    else return QVariant();
    }
    

    Isn't it obvious that you will get "Project" always for "ItemType" ?

    157

    I 1 Reply Last reply 2 Nov 2015, 07:37
    1
    • P p3c0
      2 Nov 2015, 06:23

      @illunara According to your earlier code:

      QVariantMap TreeViewDataModel::get(QModelIndex index) {
      ModelAbstract* model = static_cast<ModelAbstract*>(index.internalPointer());
      qDebug() << model->getData("ItemType");
      return QVariantMap();
      

      You are fetching data for "ItemType". And now the definition of getData:

      virtual QVariant    getData(QString dataname) const;
      QVariant    Project::getData(QString dataname) const {
      if(dataname == "ItemDisplayName") {
          QVariantMap returnData;
          returnData["ItemDisplayName"] = m_name;
          returnData["ItemType"] = m_type;
          return returnData;
      } else if(dataname == "ItemType")
          return "Project";
      else return QVariant();
      }
      

      Isn't it obvious that you will get "Project" always for "ItemType" ?

      I Offline
      I Offline
      illunara
      wrote on 2 Nov 2015, 07:37 last edited by illunara 11 Feb 2015, 07:37
      #22

      @p3c0 You are right, my horrible mistake. I think i drunk, should get home now :(
      I marked this topic as solved, should i some delete needless post too?

      P 1 Reply Last reply 2 Nov 2015, 08:38
      0
      • I illunara
        2 Nov 2015, 07:37

        @p3c0 You are right, my horrible mistake. I think i drunk, should get home now :(
        I marked this topic as solved, should i some delete needless post too?

        P Offline
        P Offline
        p3c0
        Moderators
        wrote on 2 Nov 2015, 08:38 last edited by
        #23

        @illunara That's fine. No need to delete. It might confuse.

        157

        1 Reply Last reply
        0

        21/23

        2 Nov 2015, 06:23

        • Login

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