Solved:
the problem that the app crashed on column 0 was that I set
this->setCellWidget(row, col, status);
this->setCellWidget(row, col, status);
To copy to clipboard, switch view to plain text mode
so there wasn't any item there
I just put an empty item and it worked
this->setItem(row, col, statusItem);
this->setCellWidget(row, col, status);
QTableWidgetItem *statusItem = new QTableWidgetItem;
this->setItem(row, col, statusItem);
this->setCellWidget(row, col, status);
To copy to clipboard, switch view to plain text mode
The reason that it shows menu on column 2 was that I simply printed it anyway, I just missed that.
void ListView
::provideContexMenu(const QPoint &position
) { selectedItem = this->itemAt(position.x(), position.y());
if (selectedItem->column() == 1) {
menu->addAction(shareAct);
menu->addAction(openAct);
menu->addAction(viewAct);
}
menu
->exec
(QCursor::pos());
// HERE , STUPID ...}
void ListView::provideContexMenu(const QPoint &position) {
selectedItem = this->itemAt(position.x(), position.y());
if (selectedItem->column() == 1) {
menu->addAction(shareAct);
menu->addAction(openAct);
menu->addAction(viewAct);
menu->exec(QCursor::pos());
}
menu->exec(QCursor::pos()); // HERE , STUPID ...
}
To copy to clipboard, switch view to plain text mode
also this works either
selectedItem = this->itemAt(position);
selectedItem = this->itemAt(position);
To copy to clipboard, switch view to plain text mode
instead
selectedItem = this->itemAt(position.x(), position.y());
selectedItem = this->itemAt(position.x(), position.y());
To copy to clipboard, switch view to plain text mode
Bookmarks