• 4362阅读
  • 5回复

这个程序有问题,大家来帮忙改下吧,谢谢。 [复制链接]

上一主题 下一主题
离线zyysql
 
只看楼主 正序阅读 楼主  发表于: 2010-03-21
以前在学JAVA。现在来学一下C++这东东。感觉QT和JAVA很相似。自己想当然的写了这个程序,编能过就是不能运行。希望高手来帮忙改下。不胜感激!!
#include <QtGui/QApplication>
#include <QHBoxLayout>
#include <qslider.h>
#include <qspinbox.h>

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QHBoxLayout *layout=new QHBoxLayout();
    layout->setMargin(6);

    QSpinBox *spinBox=new QSpinBox((QWidget*)layout);
    QSlider *slider=new QSlider(Qt::Horizontal,(QWidget*)layout);
    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->setValue(35);

    layout->addWidget(spinBox);
    layout->addWidget(slider);


    app.setMainWidget((QWidget*)layout);
    //qt_2 w;
    //w.show();
    return app.exec();
}
离线benbenmajia

只看该作者 5楼 发表于: 2010-03-22
建议你从最简单的开始学起,特别是QT中界面的显示,没仔细看怎么可以
安然.....
离线zyysql
只看该作者 4楼 发表于: 2010-03-21
谢谢。。。。呵呵
离线hover_sky

只看该作者 3楼 发表于: 2010-03-21
main.cpp

  1. #include <QtGui/QApplication>
  2. #include "widget.h"
  3. int main(int argc, char *argv[])
  4. {
  5.     QApplication a(argc, argv);
  6.     Widget w;
  7.     w.show();
  8.     return a.exec();
  9. }
离线hover_sky

只看该作者 2楼 发表于: 2010-03-21
widget.cpp

  1. #include "widget.h"
  2. #include <QHBoxLayout>
  3. #include <QSpinBox>
  4. #include <QSlider>
  5. Widget::Widget(QWidget *parent) :
  6.     QWidget(parent)
  7. {
  8.     QHBoxLayout *layout=new QHBoxLayout(this);
  9.     layout->setMargin(6);
  10.     QSpinBox *spinBox=new QSpinBox;
  11.     QSlider *slider=new QSlider(Qt::Horizontal);
  12.     spinBox->setRange(0,130);
  13.     slider->setRange(0,130);
  14.     QObject::connect(spinBox,SIGNAL(valueChanged(int)),slider,SLOT(setValue(int)));
  15.     QObject::connect(slider,SIGNAL(valueChanged(int)),spinBox,SLOT(setValue(int)));
  16.     spinBox->setValue(35);
  17.     layout->addWidget(spinBox);
  18.     layout->addWidget(slider);
  19. }
离线hover_sky

只看该作者 1楼 发表于: 2010-03-21
widget.h

  1. #ifndef WIDGET_H
  2. #define WIDGET_H
  3. #include <QWidget>
  4. #include <QNetworkReply>
  5. #include <QList>
  6. #include <QSslError>
  7. class Widget : public QWidget {
  8.     Q_OBJECT
  9. public:
  10.     Widget(QWidget *parent = 0);
  11. };
  12. #endif // WIDGET_H
快速回复
限100 字节
 
上一个 下一个