Results 1 to 3 of 3

Thread: Adding QComboBox to QTableWidget very slow

  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 12:14.

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

    Default Re: Adding QComboBox to QTableWidget very slow

    Someone else is also having a similar problem but there has not been a reply to it.

    Can some one please help me?

    Thanks a lot

  3. #3
    Join Date
    Jan 2006
    Location
    India
    Posts
    115
    Thanks
    3
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Adding QComboBox to QTableWidget very slow

    QTableWidget is trying to initialise the widget (which you set) by setting the text property, which QComboBox does not has, so the said messages occur. You can verify this by using QLineEdit (or any widget which has the text property). I think Qt will have to have some changes in the behaviour setCellWidget() and other related functions operate. Someone please correct me if I am wrong, as I've not used this feature yet.

    What purpose do the combo box serve? If you are using them for editing (via selecting from a list of possible values) you can consider having a custom item delegate, I'm using same method for myself with success.

Similar Threads

  1. QComboBox inside QTableWidget
    By campana in forum Qt Programming
    Replies: 7
    Last Post: 20th March 2006, 18:22
  2. Replies: 6
    Last Post: 5th March 2006, 22:05
  3. [QT3] QComboBox: Disable adding items on Enter-keypress
    By BrainB0ne in forum Qt Programming
    Replies: 7
    Last Post: 14th January 2006, 20: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.