2015-08-08 120 views
0

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 expansionQt Creator的VS 2013(错误C1057)

#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(); 
} 

回答

2

你的括号是从比赛上你的连接语句。

更改您的线路:

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

,并应照顾你。

当QtCreator在连接语句上自动完成时,它通常不会添加结束括号。它引起了我很多次。

+0

谢谢,它运作良好 –