TableWidget Edit Diabled or Remove random rows ?
-
Using table Widget im creating One table which is contain 5 colum and several rows more than 100
I want to disable Editable future of Table and I want to select row and delete.In Advance Thank U.
-
Using table Widget im creating One table which is contain 5 colum and several rows more than 100
I want to disable Editable future of Table and I want to select row and delete.In Advance Thank U.
-
Using table Widget im creating One table which is contain 5 colum and several rows more than 100
I want to disable Editable future of Table and I want to select row and delete.In Advance Thank U.
@Pranit-Patil said in TableWidget Edit Diabled or Remove random rows ?:
I want to disable Editable future
https://doc.qt.io/qt-5/qabstractitemview.html#editTriggers-prop
I want to select row
https://doc.qt.io/qt-5/qabstractitemview.html#selectionModel
https://doc.qt.io/qt-5/qitemselectionmodel.html#selectedRows -
I implement like this- but in this if i click delete option created and if i clicked on delete row will be deleted
problem is when i not selected delete option im click anywhere row will be deletedplz help me
int PoMo::on_tableWidget_customContextMenuRequested(const QPoint &pos) { QMenu *menu=new QMenu(this); QAction *del=new QAction("delete",this); menu->addAction(del); menu->exec(QCursor::pos()); if (DGparaCount == 1) { no_s--; } no_p--; DGparaCount--; uiPoMo->tableWidget->removeRow(uiPoMo->tableWidget->currentRow()); a1--; }
-
I implement like this- but in this if i click delete option created and if i clicked on delete row will be deleted
problem is when i not selected delete option im click anywhere row will be deletedplz help me
int PoMo::on_tableWidget_customContextMenuRequested(const QPoint &pos) { QMenu *menu=new QMenu(this); QAction *del=new QAction("delete",this); menu->addAction(del); menu->exec(QCursor::pos()); if (DGparaCount == 1) { no_s--; } no_p--; DGparaCount--; uiPoMo->tableWidget->removeRow(uiPoMo->tableWidget->currentRow()); a1--; }
@Pranit-Patil Please read documentation: http://doc.qt.io/qt-5/qmenu.html#exec
"This returns the triggered QAction in either the popup menu or one of its submenus, or 0 if no item was triggered (normally because the user pressed Esc)."
You currently don't check whether the delete action was triggered or not.if (menu->exec(QCursor::pos()) != nullptr) { uiPoMo->tableWidget->removeRow(uiPoMo->tableWidget->currentRow()); }