为什么在第17行和第18行我得到错误的代码Q::object…它说我需要把')'放在';'我很困惑,请帮助。
#include <QtGui>
#include <QHBoxLayout>
#include <QSlider>
#include <QSpinBox>
int main(int argc, char *argv[]){
QGuiApplication prog(argc, argv);
QWidget *mainWindow = new QWidget;
mainWindow->setWindowTitle("how many chickens do you want");
QSpinBox *spinner = new QSpinBox;
QSlider *slider = new QSlider(Qt::Horizontal);
spinner->setRange(1,50);
slider->setRange(1,50);
QObject::connect(spinner, SIGNAL(valueChanged(int)),slider, SLOT(setValue(int));
QObject::connect(slider, SIGNAL(valueChanged(int)),spinner, SLOT(setValue(int));
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(spinner);
layout->addWidget(slider);
mainWindow->setLayout(layout);
mainWindow->show();
你每一行都短一个')'。试试这个:
QObject::connect(spinner, SIGNAL(valueChanged(int)),slider, SLOT(setValue(int)));
QObject::connect(slider, SIGNAL(valueChanged(int)),spinner, SLOT(setValue(int)));