Results 1 to 3 of 3

Thread: How to get value from QCombobox which is configured as QWidget in QTableWidget ??

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2017
    Posts
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default How to get value from QCombobox which is configured as QWidget in QTableWidget ??

    Hello All,

    I have created a Qcombobox as a Qwidget in a QtableWidget and it is working fine, The below code i have used for creating combobox in table widget.

    Qt Code:
    1. QWidget *pWidget1 = new QWidget();
    2. QComboBox *ipcombo = new QComboBox;
    3. QHBoxLayout * pLayout1 = new QHBoxLayout(pWidget1);
    4. pLayout1->addWidget(ipcombo);
    5. pLayout1->setAlignment(Qt::AlignCenter);
    6. pLayout1->setContentsMargins(0,0,0,0);
    7. pWidget1->setLayout(pLayout1);
    8. ipcombo->addItem("YES");
    9. ipcombo->addItem("NO");
    10. ui->tableWidget->setCellWidget(1,3,pWidget1);
    11. connect(ipcombo, SIGNAL(currentIndexChanged(QString)),this,SLOT(on_currentIndexChanged(QString)));
    12. index++;
    To copy to clipboard, switch view to plain text mode 

    now the problem is i couldn't get the data out of the combobox which is assigned as a cellwidget. the below code only am using to get the data. if the button is clicked the SIGSEGV segmentation fault error is happening.

    Qt Code:
    1. void MainWindow::on_submitbtn_2_clicked()
    2. {
    3. QStringlist ComboData;
    4. QComboBox *myCB = qobject_cast<QComboBox*>(ui->tableWidget_2->cellWidget(row,3));
    5. Combodata<< myCB->currentText();
    6. }
    To copy to clipboard, switch view to plain text mode 

    Kindly help me
    thanks in advance..
    Last edited by high_flyer; 21st December 2017 at 10:25. Reason: missing [code] tags

Similar Threads

  1. Access QComboBox inside QTableWidget
    By phil333 in forum Qt Programming
    Replies: 4
    Last Post: 27th February 2017, 16:29
  2. QTableWidget and QCombobox
    By Stanfillirenfro in forum Qt Programming
    Replies: 2
    Last Post: 30th December 2013, 17:58
  3. Again QTableWidget and QComboBox delegate
    By Aki-Matti in forum Qt Programming
    Replies: 2
    Last Post: 4th March 2008, 13:40
  4. Adding QComboBox to QTableWidget very slow
    By munna in forum Qt Programming
    Replies: 2
    Last Post: 13th July 2006, 15:45
  5. QComboBox inside QTableWidget
    By campana in forum Qt Programming
    Replies: 7
    Last Post: 20th March 2006, 17:22

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.