Forum
Sign Up
× DataGrid for Qt.C++

How to know if selection is valid

8 years 5 months ago #1 by Pascal
I have below code:
    Qtitan::GridTableView* view = ui->gridSites->view<Qtitan::GridTableView>();
    GridSelection* selection = view->selection();

    if (selection) {
        QModelIndex idIndex = m_pSiteTableModel->index(selection->row()->modelRowIndex(),SiteTableModel::id);
        .... 
   }
In some cases selection->row() causes an exception (eg empty grid model, grid is filtered and no rows)

How can I verify selection is valid ?

Thanks

P

Please Log in or Create an account to join the conversation.

More
  • Not Allowed: to create new topic.
  • Not Allowed: to reply.
  • Not Allowed: to edit your message.
Moderators: Developer Machines
Time to create page: 0.111 seconds

Developer Newsletter

Join our Developer Machines newsletter to get informed on all the latest releases of the commercial components for Qt.C++, Delphi FireMonkey, updates and general knowledges.

Quick Support

Should you need any additional information about our products or licensing, please contact us at the following email addresses:

  • This email address is being protected from spambots. You need JavaScript enabled to view it.

  • This email address is being protected from spambots. You need JavaScript enabled to view it.

Get in Touch

If you would like to purchase our products or services, but don’t know how to do it the right way, please feel free to contact us:

  • This email address is being protected from spambots. You need JavaScript enabled to view it.( any questions related to our products or services )
  • This email address is being protected from spambots. You need JavaScript enabled to view it.( questions related to licensing )