为什么我会得到预期')'之前';' qt5

时间:2015-10-21 00:11:39

标签: qt5

为什么我在第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();

1 个答案:

答案 0 :(得分:2)

你缩短了一个&#39;)&#39;在每一行。试试这个:

QObject::connect(spinner, SIGNAL(valueChanged(int)),slider, SLOT(setValue(int)));

QObject::connect(slider, SIGNAL(valueChanged(int)),spinner, SLOT(setValue(int)));