Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTreewidgetitem not shown in QTree Widget
Forum Updated to NodeBB v4.3 + New Features

QTreewidgetitem not shown in QTree Widget

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.0k 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.
  • T Offline
    T Offline
    tan3587
    wrote on last edited by
    #1

    Hi All,

    I have a Qtreewidget named treewidget in my UI. I am adding another qtreewidget named temptree that will copy selective items from treewidget to temptree. The code is compiling fine but I am unable to see any item in temptree. Following is my code:

    in the constructor I have set temptree->hide();
    And in the fuction to copy treewidget to temptree:
    @void ImageVideoManagerWidget::on_pushButton_clicked()
    {
    temptree = new QTreeWidget();
    ui->verticalLayout->addWidget(temptree);
    ui->widget_2->setLayout(ui->verticalLayout);
    temptree->setMaximumSize(520,550);
    temptree->setMinimumSize(520,550);
    temptree->setIndentation(10);
    temptree->setColumnCount(5);
    temptree->setColumnWidth(0,120);

    QStringList list;
    list<<"Image"<<"TimeStamp"<<"Source"<<"Width"<<"Height";
    temptree->setHeaderLabels(list);
    temptree->clear();
    
    //ui->slidertree->show();
    

    // ui->slidertree->clear();
    int time = ui->timeslider->value();
    qDebug()<<time;
    QTreeWidgetItem *item;

    int j=0;
    int flag=0,ok;
    //settree_show();
    settree_hide();
    
       // int time = ui->timelabel->text().toInt(&ok,10);
    for( j=0;j<ui->treeWidget->topLevelItemCount();j++)
    {
        item = ui->treeWidget->topLevelItem(j);
        qDebug()<<"here in loop 1";
        if(time<=item->toolTip(1).toInt())
        {
            flag = 1;
            qDebug()<<"here in loop 1"<<item->toolTip(1)<<flag;
            break;
        }
    }
    qDebug()<<"here out loop 1"<<item->childCount();
    if (flag ==1)
    for( j=0;j<item->childCount();j++)
    
    {
        //qDebug()<<"here in loop 2"<<item->child(j)->toolTip(1);
        if(time<=item->child(j)->toolTip(1).toInt())
    
        {   qDebug()<<"here in loop 2"<<item->child(j)->toolTip(1);
            flag=2;
            item=item->child(j);
            break;
        }
    
    }
    qDebug()<<"here out loop 2"<<flag;
    if (flag ==2)
    for(int k=0;k<item->childCount();k++)
    {
        qDebug()<<"in loop 3"<<item->child(k)->toolTip(1).toInt();
        if(time<=item->child(k)->toolTip(1).toInt())
        {
        flag =3;
        qDebug()<<"here in loop 3"<<item->child(k)->toolTip(1);
        item=item->child(k);
        break;
        }
    }
    
    j=0;
    if (flag ==1)
        {
        qDebug()<<"here in loop 4";
        if(time==item->toolTip(1).toInt())
        temptree->insertTopLevelItem(0,item);
        }
    else
    for(int i=0;i<item->childCount();i++)
    {
    
       if(time==item->child(i)->toolTip(1).toInt())
       {
           //ui->image_view->setText(item->child(i)->text(1));
    
        temptree->insertTopLevelItem(0,item->child(i));
        //temptree->setHidden(false);
        qDebug()<<"here in loop 5";
       }
    }
    

    temptree->show();
    qDebug()<<"here out loop 5";

    }@

    Can some one please help me in deciphering where the error is??

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