Colomn child in QTreeView [SOLVED]

  • Hello,
    I have a problem to setData in the colomun of a child in QTreeView.
    This actually what it do:

    And this is what I want:

    And the code:
    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:


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

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

  • I use the basic QStandardItemModel and QStandardItem.

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

  • The solution of my problem is this:

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

    Hope it help

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.