Multi-event handlers
#include <QApplication> #include <QVBoxLayout> #include <QLabel> #include <QSpinBox> #include <QSlider> int main(int argc, char *argv[]) { QApplication a(argc, argv); QWidgetwindow; QVBoxLayout* mainLayout = new QVBoxLayout(&window); QLabel* label = new QLabel("0"); QSpinBox* spinBox =new QSpinBox; QSlider* slider = new QSlider(Qt::Horizontal); mainLayout->addWidget(label); mainLayout->addWidget(spinBox); mainLayout->addWidget(slider); QObject::connect(spinBox, SIGNAL(valueChanged(int)),label, SLOT(setNum(int))); QObject::connect(spinBox, SIGNAL(valueChanged(int)),slider, SLOT(setValue(int))); QObject::connect(slider, SIGNAL(valueChanged(int)),label, SLOT(setNum(int))); QObject::connect(slider, SIGNAL(valueChanged(int)),spinBox, SLOT(setValue(int))); window.show(); return a.exec(); }
1. | A Slot Responds to a Signal | ||
2. | Inherited slot | ||
3. | Qt signal test | ||
4. | Qt signals and slots | ||
5. | Quit Qt application | ||
6. | Widget style | ||
7. | QSignal mapper | ||
8. | event filters | ||
9. | Mark method with Q_INVOKABLE |