2015-08-08 64 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

謝謝,它運作良好 –