Hello!
I have a question on how to catch errors if a return-value is not accessible. I am unsure which is a good way to make sure, that a correct value is returned and what to do, if that value is not available.
The function is used to fetch values from a QDialog, called on exec().
{
//check if something is selected
if(tableView->selectionModel()->hasSelection())
{
if (index.isValid())
{
QSqlRecord record
= modelCustomer
->record
(index.
row());
return record;
}
}
else
{
//application crashes here, what should be returned?
}
QSqlRecord SelectAddress::passRecord()
{
//check if something is selected
if(tableView->selectionModel()->hasSelection())
{
QModelIndex index = tableView->currentIndex();
if (index.isValid())
{
QSqlRecord record = modelCustomer->record(index.row());
return record;
}
}
else
{
QMessageBox::warning(0, QObject::tr("Selection error"),"No entry selected");
//application crashes here, what should be returned?
}
To copy to clipboard, switch view to plain text mode
A point into the right direction would be enough.
Kind regards,
HomeR
Bookmarks