This line uses the Qt5 new-style connect() and a C++11 lambda function in place of a named slot function.
Qt Code:
  1. QObject::connect(
  2. cb,
  3. //^^^ sender object
  4. static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
  5. //^^^ a PointerToMemberFunction for the currentIndexChanged(int) signal function and not the currentIndexChanged(QString) one
  6. [&](int idx) { view->setRootIndex(model.index(idx, 0)); }
  7. //^^^ a C++11 lambda function accepting an int argument (Functor)
  8. );
  9.  
  10. // equivalent to the traditional Qt
  11.  
  12. connect(
  13. cb,
  14. SIGNAL(QComboBox::currentIndexChanged(int)),
  15. SLOT(someSlot(int))
  16. );
  17.  
  18. // with a slot function
  19. void someSlot(int idx) {
  20. view->setRootIndex(model.index(idx, 0));
  21. }
To copy to clipboard, switch view to plain text mode