Get previous value of QComboBox, which is in a QTableWidget, when the value is changed

前端 未结 4 992
长情又很酷
长情又很酷 2021-02-09 16:55

Say I have a QTableWidget and in each row there is a QComboBox and a QSpinBox. Consider that I store their values is a QMap

4条回答
  •  长情又很酷
    2021-02-09 17:45

    A bit late but I had the same problem and solved in this way:

    class CComboBox : public QComboBox
    {
       Q_OBJECT
    
       public:
          CComboBox(QWidget *parent = 0) : QComboBox(parent) {}
    
    
          QString GetPreviousText() { return m_PreviousText; }
    
       protected:
          void mousePressEvent(QMouseEvent *e)
          { 
             m_PreviousText = this->currentText(); 
             QComboBox::mousePressEvent(e); 
          }
    
       private:
          QString m_PreviousText;
    };
    

提交回复
热议问题