• 7191阅读
  • 2回复

【提问】QScrollView出错 [复制链接]

上一主题 下一主题
离线gaoyu
 
只看楼主 正序阅读 楼主  发表于: 2005-12-28
下面是我的程序:
#include <qapplication.h>
#include <qpushbutton.h>
#include <qfont.h>
#include <qscrollview.h>

class MyMainWindow:public QScrollView
{
     public:
           MyMainWindow();      
     private:
           QPushButton *b1;
};

MyMainWindow::MyMainWindow()
{
     this->setGeometry(100,100,200,100);
     b1=new QPushButton("This button is not too\n big for the window!",this);
     b1->setGeometry(10,10,180,80);
     b1->setFont(QFont("Times",18,QFont::Bold));
     addChild(b1);
}

int main(int argc,char **argv)
{
     QApplication a(argc,argv);
     MyMainWindow w;
     w.show();
     a.exec();
     return 0;
}

以下是报错信息:
[root@202 Scroll]# make
g++ -c -pipe -g -D_REENTRANT -Wall -W -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.1.0/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/Qt-4.1.0/include/QtCore -I/usr/local/Trolltech/Qt-4.1.0/include/QtGui -I/usr/local/Trolltech/Qt-4.1.0/include -I. -I. -o Scroll.o Scroll.cpp
Scroll.cpp:4:25: qscrollview.h: 没有那个文件或目录
Scroll.cpp:7: parse error before `{' token
Scroll.cpp:15: invalid use of undefined type `class MyMainWindow'
Scroll.cpp:6: forward declaration of `class MyMainWindow'
Scroll.cpp: In constructor `MyMainWindow::MyMainWindow()':
Scroll.cpp:16: invalid use of undefined type `class MyMainWindow'
Scroll.cpp:6: forward declaration of `class MyMainWindow'
Scroll.cpp:17: `b1' undeclared (first use this function)
Scroll.cpp:17: (Each undeclared identifier is reported only once for each
  function it appears in.)
Scroll.cpp:17: no matching function for call to `QPushButton::QPushButton(const
  char[44], MyMainWindow* const)'
/usr/local/Trolltech/Qt-4.1.0/include/QtGui/qpushbutton.h:87: candidates are:
  QPushButton::QPushButton(const QPushButton&)
/usr/local/Trolltech/Qt-4.1.0/include/QtGui/qpushbutton.h:45:
  QPushButton::QPushButton(const QIcon&, const QString&, QWidget* = 0)
/usr/local/Trolltech/Qt-4.1.0/include/QtGui/qpushbutton.h:44:
  QPushButton::QPushButton(const QString&, QWidget* = 0)
/usr/local/Trolltech/Qt-4.1.0/include/QtGui/qpushbutton.h:43:
  QPushButton::QPushButton(QWidget* = 0)
Scroll.cpp:20: `addChild' undeclared (first use this function)
Scroll.cpp: In function `int main(int, char**)':
Scroll.cpp:26: aggregate `MyMainWindow w' has incomplete type and cannot be
  defined
make: *** [Scroll.o] Error 1




我用的是QT4.1.0,请问是不是已经没有QScrollView类了?
离线cplus

只看该作者 2楼 发表于: 2009-02-03
好像是没有了,有QScrollArea
离线jzj139
只看该作者 1楼 发表于: 2009-02-02
#include <qapplication.h>
#include <qpushbutton.h>
#include <qfont.h>
#include <qscrollview.h>
头文件不再这么写了
qt
快速回复
限100 字节
 
上一个 下一个