Results 1 to 19 of 19

Thread: How to create a Combo box in a Tablview Model

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #9
    uzairsaeed702 Guest

    Default Re: How to create a Combo box in a Tablview Model

    Quote Originally Posted by ChrisW67 View Post
    The example you link to is exactly the sort of thing you need to be be doing.
    Hey ChrisW67,

    Yes true but in that example everything is handled by QSqlTableModel class which automatically detects the queries and place the combo box where it is necessary , which is invalid in my case. My model
    TableModel *newTable = new TableModel(XmlMap,this)
    ui->tableView->setModel(&newTable)
    ui->tableView->setItemDelegate(&comboBoxDelegate)
    creating all the necessary data structure depending on the length of Xmlmap and if i put the delegate then it'll create the combo box with in all the table cell which is what i don't want.

    I am thinking to switch on QTableWidget but i have much data to view and on the other hand i am thinking that TableWidget will be slow.

    I have tried a simple example through QTableWidget "Quick try"

    Qt Code:
    1. QTableWidgetItem *newItem = new QTableWidgetItem("a");
    2. ui->tableWidget->setItem(count, columns,newItem);
    3. columns++;
    4. QTableWidgetItem *newItem1 = new QTableWidgetItem("b");
    5. ui->tableWidget->setItem(count, columns, newItem1);
    6. columns++;
    7. QTableWidgetItem *newItem2 = new QTableWidgetItem("c");
    8. ui->tableWidget->setItem(count, columns, newItem2);
    9. QComboBox* comboBox = new QComboBox();
    10. comboBox->addItem("modeMap");
    11.  
    12. QComboBox* comboBox2 = new QComboBox();
    13. comboBox2->addItem("valueMap");
    14. ui->tableWidget->setCellWidget(count,3,comboBox);
    15. ui->tableWidget->setCellWidget(count,4,comboBox2);
    To copy to clipboard, switch view to plain text mode 

    And in last i got a good result and it is too easy to handle, but the only problem that it is taking some time to load because my xml contain 1500 rows.

    New.jpg
    Last edited by uzairsaeed702; 14th January 2015 at 09:50.

Similar Threads

  1. Create Complex combo control
    By frsdot in forum General Programming
    Replies: 1
    Last Post: 20th October 2013, 15:14
  2. Replies: 1
    Last Post: 11th June 2013, 16:56
  3. Value from combo box to LCD
    By dayo30 in forum Qwt
    Replies: 4
    Last Post: 1st February 2013, 00:40
  4. How to create Combo box using QML in Qt
    By Channareddy in forum Newbie
    Replies: 0
    Last Post: 4th July 2011, 05:47
  5. Is it possible to create a combo with paper sizes?
    By aekilic in forum Qt Programming
    Replies: 10
    Last Post: 19th January 2010, 09:16

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