错误如下
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/opt/qtsdk-2010.05/qt/mkspecs/linux-g++ -I. -I/opt/qtsdk-2010.05/qt/include/QtCore -I/opt/qtsdk-2010.05/qt/include/QtGui -I/opt/qtsdk-2010.05/qt/include -I. -I. -o a.o a.cpp
a.cpp: In function ‘int main(int, char**)’:
a.cpp:17: 错误:从类型‘int’到类型‘QLayout*’的转换无效
a.cpp:17: 错误: 初始化‘void QWidget::setLayout(QLaI_LI`
代码如下
#include"QApplication"
#include"QHBoxLayout"
#include"QSlider"
#include"QSpinBox"
int main(int argc,char **argv)
{ QApplication app(argc,argv);
QWidget *window=new QWidget;
window->setWindowTitle("Enter Your Age");
QSpinBox *spinBox=new QSpinBox;
QSlider *slider=new QSlider(Qt::Horizontal);
spinBox->setRange(0,130);
slider->setRange(0,130);
QObject::connect(spinBox,SIGNAL(valueChanged(int)),
slider,SLOT(setValue(int)));
QObject::connect(slider,SIGNAL(valueChanged(int)),
spinBox,SLOT(setValue(int)));
spinBox->setLayout(35);
QHBoxLayout *layout=new QHBoxLayout;
layout->addWidget(spinBox);
layout->addWidget(slider);
window->setLayout(layout);
window->show();