Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Colomn child in QTreeView [SOLVED]
Qt 6.12 LTS is out! See what's new in the release blog

Colomn child in QTreeView [SOLVED]

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.3k Views 1 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hello,
    I have a problem to setData in the colomun of a child in QTreeView.
    This actually what it do:
    !http://img4.hostingpics.net/pics/57875218p.png!

    And this is what I want:
    !http://img4.hostingpics.net/pics/33945391q.png!

    And the code:
    @qsObjetCle->appendRow(qsObjetAppel);
    QModelIndex qmIndexObjetsCle = qsModel->indexFromItem(qsObjetCle);
    bool i;
    i = qsModel->setData(qsModel->index(0,1,qmIndexObjetsCle),ObjetAppele->iVersion);@

    qsObjetCle represent "Package" and "PinAssign".
    qsObjetAppel represent "Projet 5" and "Projet 6".
    qsModel it's the model assign to my QTreeView.

    When I add a breakpoint, I see the boolean i is false, setData failed.
    When I change the index to 0,0, it do this:

    !http://img4.hostingpics.net/pics/824030Sanstitre.png!

    We can see when I focus a child, he haven't the root Column.
    Any idea how to solve it ?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      Without seeing the implementation of your model: how can we tell? What kind of model are you using at all?

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        I use the basic QStandardItemModel and QStandardItem.

        @QStandardItemModel qsModel = new QStandardItemModel();
        ui->treeViewBDD->setModel(qsModel);
        QStandardItem *qsObjetCle = new QStandardItem(sCle.c_str());
        QStandardItem *qsObjetAppel = new QStandardItem(QIcon::QIcon(QString::fromStdString(sImage)),itLien->c_str());@

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          The solution of my problem is this:

          @QStandardItem qsColonne= new QStandardItem(ObjetAppele->iVersion);
          qsObjetCle->appendColumn(QList<QStandardItem *>() << qsColonne);@

          Hope it help

          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
          • Unsolved