Results 1 to 3 of 3

Thread: Loading QTableWidget using QTimer like batch processing, but application holds

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2011
    Location
    Bangalore
    Posts
    254
    Thanks
    92
    Thanked 16 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Loading QTableWidget using QTimer like batch processing, but application holds

    I'm parsing a XML file (size varies between 500K & 90 M) and the output of parse is a QStringList. Each index in the stringlist is split based on a seperator & the data is loaded into the table.
    So when I try to load the data into table, the application doesn't respond till the loading is complete. So I decided to do the processing in QTimer. But still the application behaves the same way while the table gets loaded with data. I tried to debug this, but the debugger isn't stopping at the break-point.

    This is how I've done -
    Qt Code:
    1. // cresultstable.h
    2. class CResultsTable : public QTableWidget
    3. {
    4. Q_OBJECT
    5. public:
    6. CResultsTable(QString fName, QWidget *parent = 0);
    7.  
    8. private:
    9. QTimer *batchTimer;
    10.  
    11. .... // other widgets
    12.  
    13. private slots:
    14. void batchLoadRecords(string str, int nRow);
    15.  
    16. public slots:
    17. void loadTable(); // This will be called on signal
    18. };
    To copy to clipboard, switch view to plain text mode 

    This is how I'm calling timer, timeout() to process data -
    Qt Code:
    1. // cresultstable.cpp
    2. CResultsTable::CResultsTable(QString fName, QWidget *parent) :
    3. QTableWidget(parent)
    4. {
    5. ... // other initializations
    6. ...
    7.  
    8. batchTimer = new QTimer(this);
    9. connect(batchTimer, SIGNAL(timeout()), this, SLOT(batchLoadRecords(string, int)));
    10. };
    11.  
    12. void CResultsTable::loadTable()
    13. {
    14. XMLParser *xmlParse;
    15. xmlParse= new XMLParser();
    16.  
    17. xmlParse->Parse();
    18. std::vector<std::string> info = xmlParse->GetInfo(); // info contains the data of parsed XML document
    19.  
    20. int numOfItems = info.size();
    21. setRowCount(numOfItems);
    22. batchTimer->start(); // Starting the timer here;
    23. // Giving timeout of 0 because Qt doc says : "QTimer with a timeout of 0 will time out as soon as all the events
    24. //in the window system's event queue have been processed. This can be used to do heavy work while
    25. //providing a snappy user interface"
    26.  
    27.  
    28. for(it = info.begin(); it != info.end(); it++)
    29. {
    30. std::string str = *it;
    31. // Here I'm trying to load
    32. batchLoadRecords(str, nRow); // Put a break-point here but it's not stopping
    33. nRow++;
    34. }
    35. batchTimer->stop();
    36. emit sig_LoadComplete();
    37. delete xmlParse;
    To copy to clipboard, switch view to plain text mode 

    How do I make the application to behave normally without holding the application event, even while loading data ? Kindly help me with this.
    Thank you.
    Last edited by rawfool; 24th June 2013 at 15:25.

Similar Threads

  1. Slow loading of data into QTableWidget
    By KenJustKen in forum Qt Programming
    Replies: 5
    Last Post: 11th April 2012, 16:50
  2. Problem loading multiple GIF images in qtablewidget.
    By sanket.mehta in forum Qt Programming
    Replies: 2
    Last Post: 13th September 2010, 11:31
  3. File Processing Application Quirk
    By sgrant327 in forum Qt Programming
    Replies: 1
    Last Post: 9th September 2010, 19:55
  4. Replies: 3
    Last Post: 2nd October 2009, 00:19
  5. QTimer - too many in application??
    By db in forum Newbie
    Replies: 4
    Last Post: 31st March 2008, 16:12

Tags for this Thread

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.