Minor bugs in the practice process:
When I right-clicked on the view margin, that is, I did not select the row with the content, the program was interrupted because I did not make positional judgments and directly get the row content assigned to other variables.
QModelIndex temp = m->index(right_click.row(),1);
Solution:
Determines whether the selected row is within the line range of our model.
How do I get the line of the model?
ui.table_view->model()->rowCount();
Actually, we don't need to use
right_click.row() < ui.table_view->model()->rowCount();
Since the display of the TableView in the array, starting from table 0 to rowCount-1, and the downward margin is indicated by-1.
So all we have to do is to determine if the currently clicked row equals-1, that is, the blank space is selected, and no data extraction is required.
if( right_click.row() != -1 ){ //dofor you}else{}
Qtableview Right-click menu to determine whether the position is reasonable