Results 1 to 3 of 3

Thread: Adding QComboBox to QTableWidget very slow

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Adding QComboBox to QTableWidget very slow

    Hi,

    I read a text (csv) file to populate a QTableWidget. The first row contains QComboBox in all the columns. I see that when I do not add any combo box, the table is populated very quickly whereas when I add combo box, it takes a very long time for the table to get populated.

    Is there a solution to this?

    Here is the code:

    Qt Code:
    1. void TextFileImporter::importData(const QStringList &lineList)
    2. {
    3. dataTable->setRowCount(lineList.count()+1);
    4.  
    5. for(int i = 0; i < lineList.count(); ++i){
    6. QStringList columnList = lineList.at(i).split(",");
    7. for(int j = 0; j < columnList.count(); ++j){
    8. if(dataTable->columnCount() == 0){
    9. dataTable->setColumnCount(columnList.count());
    10. }
    11. if(i == 0){
    12. dataTable->addFieldCombo(j);//If comment this line then things are very fast
    13. }
    14. QString cellString = columnList.at(j);
    15. cellString.remove("\"");
    16. dataTable->insertItemAt(i+1,j,cellString);
    17. }
    18. }
    19. }
    20.  
    21. void DataTable::addFieldCombo(const int column)
    22. {
    23. QComboBox *fieldCombo = new QComboBox(this);
    24. populateFieldCombo(fieldCombo);//This line is not making much a difference
    25.  
    26. setCellWidget(0,column,fieldCombo);
    27. }
    To copy to clipboard, switch view to plain text mode 

    In the debug window I get the following message (lots of time)

    QComboBox::setProperty("text", value) failed: property invalid, read-only or does not exist

    Any Idea?
    Last edited by munna; 13th July 2006 at 11:14.

Similar Threads

  1. QComboBox inside QTableWidget
    By campana in forum Qt Programming
    Replies: 7
    Last Post: 20th March 2006, 17:22
  2. Replies: 6
    Last Post: 5th March 2006, 21:05
  3. [QT3] QComboBox: Disable adding items on Enter-keypress
    By BrainB0ne in forum Qt Programming
    Replies: 7
    Last Post: 14th January 2006, 19:43

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.