How to get the row-index when click pushbutton in qtablewidget ?
-

QPushButton* TableWidget::createSettingBtn() { QPushButton* btn = new QPushButton(tr("Settings")); btn->setStyleSheet("margin-left: 6px; margin-right: 6px; margin-top: 2px; margin-bottom: 2px;"); return btn; } ... setCellWidget(0, 3, createSettingBtn()); ...When click
Settingpushbutton, I will exec the corresponding settingDialog( I use QList to manage all settingDialogs ).So, before I exec the settingDialog, I must get the row-index according to the clicked pushbutton. So I use
QTableWidget::currentRow()to get the row-index, but it failed, because when I firstly exec the program and click the pushbutton,QTableWidget::currentRow()will return-1.And then , I use QTableWidget's signals to get the row-index, such as
cellActivated(int row, int column)etc..., but all failed.So, How to get the row-index when click pushbutton in qtablewidget? Thanks in advance.
-

QPushButton* TableWidget::createSettingBtn() { QPushButton* btn = new QPushButton(tr("Settings")); btn->setStyleSheet("margin-left: 6px; margin-right: 6px; margin-top: 2px; margin-bottom: 2px;"); return btn; } ... setCellWidget(0, 3, createSettingBtn()); ...When click
Settingpushbutton, I will exec the corresponding settingDialog( I use QList to manage all settingDialogs ).So, before I exec the settingDialog, I must get the row-index according to the clicked pushbutton. So I use
QTableWidget::currentRow()to get the row-index, but it failed, because when I firstly exec the program and click the pushbutton,QTableWidget::currentRow()will return-1.And then , I use QTableWidget's signals to get the row-index, such as
cellActivated(int row, int column)etc..., but all failed.So, How to get the row-index when click pushbutton in qtablewidget? Thanks in advance.