Application crashes if no there selected row on a qtablewidget
Code:
QVariant row
= ui...._tableWidget
->currentRow
();
if (row.toBool()) {
atual_row = row.toInt();
...
or
Code:
if (ui...._tableWidget->currentRow()) {
...
It´s crasshing my application if no row is selected on qtablewidget. The copilation is ok.
Alternativily, how to known if some row is selected or no on qtablewidget?
I use Qt 4.1.3, MingW, Windows XP.
Re: Application crashes if no there selected row on a qtablewidget
"current" and "selected" is not the same. You are not checking the selection here.
Re: Application crashes if no there selected row on a qtablewidget
If I select a item on qtablewidget, the currentRow() function returns the number of row selected, or of the current row? Or not?
I just want to know if some row or item is selected on table. The solution in my code is crasshing on execution. The code is in a custom slot function connected with a pushbutton. When I click the button, if no item or row of the table is selected, crashes, if there selection, works ok.
Re: Application crashes if no there selected row on a qtablewidget
Quote:
Originally Posted by marcelrc
If I select a item on qtablewidget, the currentRow() function returns the number of row selected, or of the current row? Or not?
"Current" item is the one which has the keyboard focus (thus there is always a "current row" if the widget has focus). "Selected" item is an item, which is highlighted by a changed background in most widget styles. There can be many selected items but only one current item.
Quote:
I just want to know if some row or item is selected on table. The solution in my code is crasshing on execution. The code is in a custom slot function connected with a pushbutton. When I click the button, if no item or row of the table is selected, crashes, if there selection, works ok.
Use QTableWidget::selectedItems() to retrieve a list of selected items. If the list is empty, no items are selected.
Re: Application crashes if no there selected row on a qtablewidget
:D
Thak you very much wysota! It's solved my problem!
You are fast to response.
I think you was hired by somebody only to response this forum. Is this your job?
Re: Application crashes if no there selected row on a qtablewidget
Quote:
Originally Posted by marcelrc
I think you was hired by somebody only to response this forum. Is this your job?
No, I do it in my free time (although I don't have much time free now).