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:
    !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 ?



  • 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();
    ui->treeViewBDD->setModel(qsModel);
    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.