Qt Creator 与 2013(错误 c1057)
Qt creator vs 2013 (error c1057)
iam trying to build this program but it give me c1057 fatal error .
When i removed connect function (line 15) it worked well and i don't
know the reason
this is the message :
C:\Users\Ahmed\Documents\Qt-App\SpinnerAndSliders\main.cpp:15: error: C1057: unexpected end of file in macro expansion
#include <QSpinBox>
#include <QSlider>
#include <QApplication>
#include <QHBoxLayout>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget *mainWindow = new QWidget();
mainWindow -> setWindowTitle("Sound volume");
QSpinBox *spinner = new QSpinBox();
QSlider *slider = new QSlider(Qt::Horizontal) ;
QHBoxLayout *layout = new QHBoxLayout ;
spinner -> setRange(0,50);
slider -> setRange(0,50);
QObject::connect(spinner,SIGNAL(valueChanged(int),slider , SLOT(setValue(int));
layout -> addWidget(spinner);
layout -> addWidget(slider);
spinner->setValue(10);
mainWindow -> setLayout(layout);
mainWindow -> show();
return app.exec();
}
您的连接语句中的括号不匹配。
将您的线路更改为:
QObject::connect(spinner,SIGNAL(valueChanged(int)),slider , SLOT(setValue(int)));
那应该会照顾到你。
当 QtCreator 自动完成连接语句时,它通常不会添加结束括号。它抓住了我很多次。
iam trying to build this program but it give me c1057 fatal error . When i removed connect function (line 15) it worked well and i don't know the reason this is the message : C:\Users\Ahmed\Documents\Qt-App\SpinnerAndSliders\main.cpp:15: error: C1057: unexpected end of file in macro expansion
#include <QSpinBox>
#include <QSlider>
#include <QApplication>
#include <QHBoxLayout>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget *mainWindow = new QWidget();
mainWindow -> setWindowTitle("Sound volume");
QSpinBox *spinner = new QSpinBox();
QSlider *slider = new QSlider(Qt::Horizontal) ;
QHBoxLayout *layout = new QHBoxLayout ;
spinner -> setRange(0,50);
slider -> setRange(0,50);
QObject::connect(spinner,SIGNAL(valueChanged(int),slider , SLOT(setValue(int));
layout -> addWidget(spinner);
layout -> addWidget(slider);
spinner->setValue(10);
mainWindow -> setLayout(layout);
mainWindow -> show();
return app.exec();
}
您的连接语句中的括号不匹配。
将您的线路更改为:
QObject::connect(spinner,SIGNAL(valueChanged(int)),slider , SLOT(setValue(int)));
那应该会照顾到你。
当 QtCreator 自动完成连接语句时,它通常不会添加结束括号。它抓住了我很多次。