Forum
Sign Up
× DataGrid for Qt.C++

SelectionChanged in DataGrid

6 months 1 week ago #1 by Alexander
Hello.
I’m new at Qt, and I have some question about using your grid.
How can I get the selectionChanged event or something similar, when I click on a row in the table.
I use just QtitanGrid and QStandardItemModel.

ui.grdTrajectory->setViewType(Qtitan::Grid::TableView);
dataFormModel = new QStandardItemModel();
dataFormModel->setHorizontalHeaderLabels(QStringList()
<< "Type" << "Duration" << "StartTime" << "EndTime" << "Acceleration" );
// Add data
ui.grdTrajectory->view<Qtitan::GridTableView>()->setModel(dataFormModel);


I need to get selected row and it’s index.

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

More
6 months 1 week ago - 6 months 1 week ago #2 by Developer Machines
To get the selection object for current state use:
Qtitan::GridTableView* view = m_grid->view<Qtitan::GridTableView>();
GridSelection* selection = view->selection();

Or connect to the view signal to get notified about the selection changes:

void GridViewBase::selectionChanged(GridSelection* selection, GridSelection* oldSelection);
connect(view, SIGNAL(selectionChanged(GridSelection *, GridSelection *)), this, SLOT(selectionChanged(GridSelection *, GridSelection *)));

See Grid_MultiSelection.exe demo example for the details.
Last edit: 6 months 1 week ago by Developer Machines.
The following user(s) said Thank You: Alexander

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 MachinesEduard
Time to create page: 0.124 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 )