Results 1 to 3 of 3

Thread: QTreeWidgetItem swap or move up one level problem

  1. #1
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QTreeWidgetItem swap or move up one level problem

    I have build a tool to manage xml tree categories on infinite level but now...
    i like insert a function to move up item or swap item ...

    My question... exist a similar function from QTreeWidgetItem to make this?
    I can access each QTreeWidgetItem by nummer




    Qt Code:
    1. void Tree_Category::AppendItemTree()
    2. {
    3. if (Maus_Select_Active) { /* active QTreeWidgetItem */
    4. /*int sotto_totale = Niagara_Actual->childCount();*/
    5. /*niagara->editItem(Niagara_Actual,0);*/
    6. /*qDebug() << "### found 0 " << sotto_totale;*/
    7. bool ok;
    8. QString SetNewName = QInputDialog::getText(this, tr("New Item append here"),tr("Name:"), QLineEdit::Normal,"", &ok);
    9. if (ok && !SetNewName.isEmpty()) {
    10. QTreeWidgetItem *newsub = new QTreeWidgetItem(Niagara_Actual);
    11. watposition++; /* numeration */
    12. QString xput = QString("[%1] %2").arg(QString::number(watposition),SetNewName);
    13. newsub->setText(0,xput);
    14. newsub->setToolTip(0,xput);
    15. PutOptionNow(newsub); /* set various option and put to other class qlist */
    16. }
    17. } else {
    18. QMessageBox::warning( this, tr( "Error" ), tr( "Select on item please!"));
    19. }
    20. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QTreeWidgetItem swap or move up one level problem

    QTreeWidget doesn't provide such functionality out of the box. This thread contains code example for swapping 2 rows in a QTableWidget. It should be rather straigthforward to adjust for QTreeWidget.
    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    patrik08 (24th September 2006)

  4. #3
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTreeWidgetItem swap or move up one level problem

    i found a solution .....

    by loading QTreeWidget and update load all text to a QStringList ....
    by move or swap select destination from a combobox QStringList

    search the destination text findname .....
    Qt Code:
    1. QList<QTreeWidgetItem*> items = niagara->findItems(findname, Qt::MatchRecursive | Qt::MatchExactly , 0);
    2.  
    3. if (items.count() == 1) {
    4. /* clone source and destination and update source to "findname" ....*/
    5. }
    To copy to clipboard, switch view to plain text mode 

    so i can swap item to all level :-) .....

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.