主题 : 求解:incomplete type 'QFileDialog' used in nested name specifier 复制链接 | 浏览器收藏 | 打印
热爱生活!寻找自我!
级别: 新手上路
UID: 40267
精华: 0
发帖: 30
金钱: 150 两
威望: 30 点
综合积分: 60 分
注册时间: 2011-03-17
最后登录: 2011-11-29
楼主  发表于: 2011-04-08 10:52

 求解:incomplete type 'QFileDialog' used in nested name specifier

我用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这个例程 按上面步骤 编译通过!
经济基础决定上层建筑!
级别: 新手上路
UID: 39514
精华: 0
发帖: 9
金钱: 45 两
威望: 9 点
综合积分: 18 分
注册时间: 2011-03-09
最后登录: 2011-04-09
1楼  发表于: 2011-04-08 14:56

 回 楼主(fancyfeeling) 的帖子

这问题嘛..是因为qte不支持qfiledialog这个类,解决办法有两个,要么自己写一个文件浏览器,要么把qpe-config里面有关禁用qfiledialog类的宏给注释掉,然后重新配置....
论坛上有某斑竹改写的filedialog的类,凑合先用下吧.........搜索一下就可以了
热爱生活!寻找自我!
级别: 新手上路
UID: 40267
精华: 0
发帖: 30
金钱: 150 两
威望: 30 点
综合积分: 60 分
注册时间: 2011-03-17
最后登录: 2011-11-29
2楼  发表于: 2011-04-08 19:36

 回 1楼(glorywings) 的帖子

谢谢,我在研究下!
经济基础决定上层建筑!
热爱生活!寻找自我!
级别: 新手上路
UID: 40267
精华: 0
发帖: 30
金钱: 150 两
威望: 30 点
综合积分: 60 分
注册时间: 2011-03-17
最后登录: 2011-11-29
3楼  发表于: 2011-04-08 20:11
已解决 1楼说的对,我也用的某斑竹改写的filedialog的类,好了,非常感谢!
我用的一个人自己写的filedialog.h 和filedialog.cpp网址如下
链接:http://www.aiothome.net/read.php?tid-4001.html
经济基础决定上层建筑!