There is a table in which the ComboBox delegate is applied to the column. How can I get the current cell value of a cell from this column?

If I do this:

QComboBox *combo = static_cast<QComboBox*>(ui->tableWidgetData->cellWidget(i,3)); combo->itemText(combo->currentIndex()); 

then the program crashes with a segmentation error.



    1 answer 1

    Understood, no? If not, put the code, try to help. Error probably due to the fact that combo is null.

    • Understood, but I implemented it not with the help of the delegate, but with the help of ui-> tableWidgetData-> setCellWidget (n-1,3, new QComboBox (combo)); By writing a connection that caught a change in the number of lines and added or removed this combo box from the cell. The delegate code from me, unfortunately, was not preserved, but I whistled the delegate at that time from here prog.org.ru/topic_9566_0.html There was another delegate, but I don’t remember where I got it from. By the way, such is the problem with the double delegate. Here is his code: - MorkOFF
    • Here is its code: class cDoubleDelegate: public QItemDelegate {Q_OBJECT public: cDoubleDelegate (QObject * parent = 0); QWidget * createEditor (QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index) const; }; - MorkOFF
    • cDoubleDelegate :: cDoubleDelegate (QObject * parent): QItemDelegate (parent) {} QWidget * cDoubleDelegate :: createEditor (QWidget * parent, const editor-> setValidator (new QDoubleValidator (editor)); editor-> setEnabled (true); return editor; } - MorkOFF