Results 1 to 13 of 13

Thread: QTreeWidgetItem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2009
    Posts
    94
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    10

    Post QTreeWidgetItem

    In QTreeWidgetItem, it is storing all data in heap memory. After filling more data performance becoming slow. Any solution for this.

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 334 Times in 317 Posts

    Default Re: QTreeWidgetItem

    How much data are you saving ? May using model would be a better way

  3. #3
    Join Date
    May 2009
    Posts
    94
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    10

    Default Re: QTreeWidgetItem

    Storing more data,result of 10,000 testcase, in this condition on run time result node is adiing to the explorer window. So after completion of 20% result node added, when i am double clicking on that node it is taking more time to open, performance becoming slower. Mouse also moving slow in the explorer window.

  4. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 334 Times in 317 Posts

    Default Re: QTreeWidgetItem

    10000 entries in a single QTreeWidgetItem ??
    Or are you creating 10000 QTreeWidgetItem objects ?

  5. #5
    Join Date
    May 2009
    Posts
    94
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    10

    Default Re: QTreeWidgetItem

    I uploaded the image, as like testcase 1, 2, there are 10,000/-.On run time result node add to each one. So after completion of 20% execution it is taking time to open the result node as well as it is taking time to scroll the scroll bar.
    Attached Images Attached Images

  6. #6
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 334 Times in 317 Posts

    Default Re: QTreeWidgetItem

    How are you adding the items into the treewidgets ? Need some code to identify the bottleneck.
    As far as I see, the 10000 number of items is slowing the process. It would be better if you use model and view instead of the QTreeWidget.

  7. #7
    Join Date
    May 2009
    Posts
    94
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    10

    Default Re: QTreeWidgetItem

    if (m_testSeqFileName.isEmpty())
    {
    SmartMsg::Info(tr("Create Test Sequence File from the Script Sequence File"));
    return; //TODO: is this required.
    }
    else
    {
    m_pTestSeqFileNode = new QTreeWidgetItem(m_pProjRoot);
    m_pTestSeqFileNode->setText(0,m_testSeqFileName);
    m_pTestSeqFileNode->setData(0,Qt::AccessibleDescriptionRole, e_TST_SEQFILE);

    // QFont font = tstSeqFileNode->font(0);
    // font.setBold(true);
    // tstSeqFileNode->setFont(0,font);
    // m_pEditor->open(m_projectFolder + QDir::separator() + m_testSeqFileName);
    }

    QStringList tstFolderList;

    for(int tcCount = 0; tcCount < m_testcaseFiles.size(); tcCount++)
    {
    QString testcaseFilePath = m_testcaseFiles[tcCount];
    QTreeWidgetItem * tstFileNode;

    if (testcaseFilePath.contains(QDir::separator()) || testcaseFilePath.contains('/'))
    {
    QChar separator;
    if (testcaseFilePath.contains(QDir::separator()))
    {
    separator = QDir::separator();
    }
    else
    {
    separator = '/';
    }

    int leftPart = testcaseFilePath.indexOf(separator);
    int rightPart = testcaseFilePath.length()-leftPart-1;

    QString testcaseFolder = testcaseFilePath.left(leftPart);
    QTreeWidgetItem * tstFolderNode;

    bool isFolderNodeExists = false;

    for (int i = 0; i < m_testCaseFolderList.count(); i++)
    {
    if (m_testCaseFolderList[i]->text(0) == testcaseFolder)
    {
    isFolderNodeExists = true;
    break;
    }
    }

    if (!isFolderNodeExists)
    {
    tstFolderNode = new QTreeWidgetItem(m_pProjRoot);
    tstFolderList.append(testcaseFolder);
    tstFolderNode->setText(0, testcaseFolder);
    tstFolderNode->setData(0,Qt::AccessibleDescriptionRole, e_FOLDER);
    m_testCaseFolderList.append(tstFolderNode);
    }

    QString testcaseFile = testcaseFilePath.right(rightPart);

    // if(tstFolderNode != NULL) // fixed crash
    // {
    tstFileNode = new QTreeWidgetItem(tstFolderNode);
    tstFileNode->setText(0, testcaseFile);
    tstFileNode->setData(0,Qt::AccessibleDescriptionRole,e_SCRFILE );
    m_pProjExpTreeWidget->expandItem(tstFolderNode);
    // }
    }
    else
    {
    tstFileNode = new QTreeWidgetItem(m_pProjRoot);
    tstFileNode->setText(0, testcaseFilePath);
    tstFileNode->setData(0,Qt::AccessibleDescriptionRole,e_SCRFILE );
    m_testCaseFolderList.append(tstFileNode);
    }

    QStringList testCaseIDs = m_mapTestcaseFileToIDs[testcaseFilePath];

    for (int i = 0; i < testCaseIDs.size(); ++i)
    {
    QTreeWidgetItem * testIDNode = new QTreeWidgetItem(tstFileNode);
    testIDNode->setText(0, testCaseIDs[i]);
    }
    m_pProjExpTreeWidget->expandItem(tstFileNode);
    }
    m_pProjExpTreeWidget->expandItem(m_pProjRoot);

  8. #8
    Join Date
    Oct 2009
    Location
    Mexico
    Posts
    81
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    6
    Thanked 10 Times in 10 Posts

    Default Re: QTreeWidgetItem

    10,000 QTreeWidgetItem consume a lot memory and procesor.

    i think is better approach use a custom model and a QTreeView. this way can implement stuff like lazy population to reduce the memory usage and other optimizations

    QTreeWidet is the best choice when only need create simple hierarchical lists. and manage 10,000 item is not a simple case.

  9. #9
    Join Date
    May 2009
    Posts
    94
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    10

    Default Re: QTreeWidgetItem

    Can you send me a example of this.

  10. #10
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanked 69 Times in 67 Posts

    Default Re: QTreeWidgetItem

    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

  11. #11
    Join Date
    May 2009
    Posts
    94
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    10

    Default Re: QTreeWidgetItem

    I saw QTreeview class but i didn't found anything to add a child of Qtreeview in the runtime. Please let me know is there is any possibility of add a child to the QTreeview dynamically?

Similar Threads

  1. The height of QTreeWidgetItem
    By Mad Max in forum Qt Programming
    Replies: 6
    Last Post: 14th May 2013, 06:38
  2. How I add rename in QTreeWidgetItem?
    By rajesh in forum Qt Programming
    Replies: 5
    Last Post: 30th March 2007, 13:10
  3. QTreeWidgetItem ?
    By allensr in forum Qt Programming
    Replies: 5
    Last Post: 3rd January 2007, 18:51
  4. QTreeWidgetItem
    By Sarma in forum Qt Programming
    Replies: 1
    Last Post: 6th April 2006, 20:52
  5. QTreeWidgetItem
    By raphaelf in forum Qt Programming
    Replies: 4
    Last Post: 5th March 2006, 16:07

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
  •  
Qt is a trademark of The Qt Company.