Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
  2. {
  3. MiTabla *tabla = new MiTabla;
  4. tabla->setModel(new MiModelo());
  5. tabla->setItemDelegate(new MiDelegado());
  6. selectionModel = tabla->selectionModel();
  7. setCentralWidget(tabla);
  8. QObject::connect(selectionModel,&QItemSelectionModel::selectionChanged,[=]()
  9. {
  10. foreach (const QModelIndex& item, selectionModel->selectedIndexes())
  11. {
  12. if (item.column()!=tabla->indiceActual().column())
  13. {
  14. selectionModel->select(item,QItemSelectionModel::Deselect);
  15. }
  16. }
  17. });
  18. }
  19.  
  20. MiTabla::MiTabla()
  21. {
  22. miSelectionModel = selectionModel();
  23. QObject::connect(this,SIGNAL(pressed(QModelIndex)),this,SLOT(CambiarIndiceACtual(QModelIndex)));
  24.  
  25. QObject::connect(miSelectionModel,&QItemSelectionModel::selectionChanged,[=]()
  26. {
  27. foreach (const QModelIndex& item, miSelectionModel->selectedIndexes())
  28. {
  29. if (item.column()!=m_indiceActual.column())
  30. {
  31. miSelectionModel->select(item,QItemSelectionModel::Deselect);
  32. }
  33. }
  34. });
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement