• 4336阅读
  • 2回复

新手make的时候出现错误 [复制链接]

上一主题 下一主题
离线416164967
 
只看楼主 倒序阅读 楼主  发表于: 2010-12-22


错误如下
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();

离线jdwx

只看该作者 1楼 发表于: 2010-12-22
这行错误: spinBox->setLayout(35);
估计是:spinBox->setValue(35);
发帖时要说明:操作系统、Qt版本、编译器,这样能更快的得到回复。
离线416164967
只看该作者 2楼 发表于: 2010-12-23
谢谢,这手段真高~~呵呵
快速回复
限100 字节
 
上一个 下一个