我用qtopia2.2.0里面的addressbook例程编译出错 求解
例程在/opt/FriendlyARM/mini2440/arm-qtopia/qtopia-2.2.0-FriendlyARM/qtopia/doc/html 目录下
我的addressbook文件夹下有如下几个文件
addressbook.desktop centralwidget.cpp mainwindow.cpp
addressbook.pro centralwidget.h mainwindow.h
build main.cpp Makefile
运行./build出西安如下错误
mainwindow.cpp: In member function 'void ABMainWindow::fileOpen()':
mainwindow.cpp:71: error: incomplete type 'QFileDialog' used in nested name specifier
mainwindow.cpp: In member function 'void ABMainWindow::fileSaveAs()':
mainwindow.cpp:90: error: incomplete type 'QFileDialog' used in nested name specifier
make: *** [.obj/release-shared/mainwindow.o] Error 1
mainwindow.cpp源代码如下:
#include "mainwindow.h"
#include "centralwidget.h"
#include <qtoolbar.h>
#include <qtoolbutton.h>
#include <qpopupmenu.h>
#include <qmenubar.h>
#include <qkeycode.h>
#include <qstatusbar.h>
#include <qapplication.h>
#include <qfiledialog.h>
ABMainWindow::ABMainWindow()
: QMainWindow( 0, "example addressbook application" ),
filename( QString::null )
{
setupMenuBar();
setupFileTools();
setupStatusBar();
setupCentralWidget();
}
ABMainWindow::~ABMainWindow()
{
}
void ABMainWindow::setupMenuBar()
{
QPopupMenu *file = new QPopupMenu( this );
menuBar()->insertItem( "&File", file );
file->insertItem( "New", this, SLOT( fileNew() ), CTRL + Key_N );
file->insertItem( QPixmap( "fileopen.xpm" ), "Open", this, SLOT( fileOpen() ), CTRL + Key_O );
file->insertSeparator();
file->insertItem( QPixmap( "filesave.xpm" ), "Save", this, SLOT( fileSave() ), CTRL + Key_S );
file->insertItem( "Save As...", this, SLOT( fileSaveAs() ) );
file->insertSeparator();
file->insertItem( QPixmap( "fileprint.xpm" ), "Print...", this, SLOT( filePrint() ), CTRL + Key_P );
file->insertSeparator();
file->insertItem( "Close", this, SLOT( closeWindow() ), CTRL + Key_W );
file->insertItem( "Quit", qApp, SLOT( quit() ), CTRL + Key_Q );
}
void ABMainWindow::setupFileTools()
{
//fileTools = new QToolBar( this, "file operations" );
}
void ABMainWindow::setupStatusBar()
{
//statusBar()->message( "Ready", 2000 );
}
void ABMainWindow::setupCentralWidget()
{
view = new ABCentralWidget( this );
setCentralWidget( view );
}
void ABMainWindow::closeWindow()
{
close();
}
void ABMainWindow::fileNew()
{
}
void ABMainWindow::fileOpen()
{
QString fn = QFileDialog::getOpenFileName( QString::null, QString::null, this ); //说此处有错
if ( !fn.isEmpty() ) {
filename = fn;
view->load( filename );
}
}
void ABMainWindow::fileSave()
{
if ( filename.isEmpty() ) {
fileSaveAs();
return;
}
view->save( filename );
}
void ABMainWindow::fileSaveAs()
{
QString fn = QFileDialog::getSaveFileName( QString::null, QString::null, this ); //说此处有错
if ( !fn.isEmpty() ) {
filename = fn;
fileSave();
}
}
void ABMainWindow::filePrint()
{
}
有的例程没出问题,我试过layout这个例程 按上面步骤 编译通过!