connect( actionDrawDot, SIGNAL( triggered() ), m_scene, SIGNAL( signalModeChanged( 1 ) ) ); connect( actionDrawLine, SIGNAL( triggered( ) ), m_scene, SIGNAL( signalModeChanged( 2 ) ) ); connect( actionDrawSquare, SIGNAL( triggered( ) ), m_scene, SIGNAL( signalModeChanged( 3 ) ) ); connect( actionDrawTrapeze, SIGNAL( triggered( ) ), m_scene, SIGNAL( signalModeChanged( 4 ) ) );
C++ (Qt)MainWindow::MainWindow() {QAction * act1 = new QAction(this);QAction * act2 = new QAction(this);QAction * act3 = new QAction(this); act1->setData(1);act2->setData(2);act3->setData(3); QActionGroup * group = new QActionGroup(this);group->addAction(act1); // Если сигналы из формы, то ui->act1group->addAction(act2);group->addAction(act3);connect(group, SIGNAL(triggered(QAction*)), this, SLOT(my_slot(QAction*)));} void MainWindow::my_slot(QAction * a) { int num = a->data().toInt(); emit m_scene->signalModeChanged(num);}
C++ (Qt)connect( actionDrawTrapeze, &QAction::triggered( ), std::bind( &MyScene::signalModeChanged, m_scene, 4 ) );