QTextBrowser显示帮助系统的问题?

软件和网站开发以及相关技术探讨
回复
自语的骆驼
帖子: 1
注册时间: 2010-03-23 12:45

QTextBrowser显示帮助系统的问题?

#1

帖子 自语的骆驼 » 2010-12-22 9:16

QTextBrowser显示帮助系统的问题?
用QtextBrowser做一个简单的帮助系统,Qt版本是Qt-embedded-3.3.8b,kubuntu上调试通过完全没有问题,并且交叉编译也没问题,但在ARM上运行到定义QTextBrowser的时候:
helpBrowser = new QTextBrowser(this,"help browser"); //运行这句的时候,系统没有反应了,好像死机了一样,ps了一下程序还在跑,我的交叉编译环境是Linux2.4.20-18的内核,开发宿主机的内核版本是Linux2.6.31.22,不知道这事怎么回事,请哪位大哥指点一下,谢谢!

以下是源代码:
/*****************************HelpInfoWnd.h**********************************/
#ifndef HELPINFOWND_H
#define HELPINFOWND_H

#include <CommonDefine.h>
#include <CommonChildWidget.h>
#include <WidgetMyLineEdit.h>
#include <qstring.h>
#include <qlabel.h>
#include <qtextbrowser.h>
#include <qmime.h>
#include <qdir.h>

class HelpInfoWnd : public CommonChildWidget
{
Q_OBJECT
public:
HelpInfoWnd(QWidget * parent = 0,const char * name = 0,WFlags fl = 0,char index = 0);
~HelpInfoWnd();
protected:
void openHelpFile(QString path);
void languageChange(void);
protected slots:
void goToHtml(void);
void showFocusAll(bool);
private:
int helpNum;

QLabel *pageNum;
WidgetMyLineEdit *helpIndex;
QLabel *helpInfoTip;

QTextBrowser *helpBrowser;
};

#endif //HELPINFOWND_H


/***************************HelpInfoWnd.cpp***********************************/
#include "HelpInfoWnd.h"

HelpInfoWnd::HelpInfoWnd(QWidget * parent,const char * name,WFlags fl,char index)
: CommonChildWidget(parent,name,fl)
{
if(!name)
setName("helpinfownd");

qDebug("HelpInfoWnd:1");
setMinimumSize(QSize(854,350)); //real data widget minimumsize
setMaximumSize(QSize(854,370)); //real data widget maximumsize
setBaseSize(QSize(854,370)); //real data widget basesize
resize(QSize(854,370).expandedTo(minimumSizeHint())); //real data widget size set

qDebug("HelpInfoWnd:2");
pageNum = new QLabel(this,"page number");
pageNum->setGeometry(QRect(20,10,60,30));

qDebug("HelpInfoWnd:3");
helpIndex = new WidgetMyLineEdit(this,"page index");
helpIndex->setGeometry(QRect(80,10,50,30));
helpIndex->setMaxLength(2);

qDebug("HelpInfoWnd:4");
helpInfoTip = new QLabel(this,"help info tip");
helpInfoTip->setGeometry(QRect(180,10,660,30));

qDebug("HelpInfoWnd:5");
helpBrowser = new QTextBrowser(this,"help browser");
qDebug("HelpInfoWnd:6");
helpBrowser->setGeometry(QRect(20,60,790,290));

qDebug("HelpInfoWnd:7");
QMimeSourceFactory *factory = helpBrowser->mimeSourceFactory();
factory->setFilePath(HelpPath);
factory->setExtensionType("htm", "text/html;charset=UTF-8");
factory->setExtensionType("html", "text/html;charset=UTF-8");
factory->setExtensionType("txt", "text/plain");
factory->setExtensionType("xml", "text/xml;charset=UTF-8");
factory->setDefaultFactory(factory);//can compile but can't work in qt 2.x

qDebug("HelpInfoWnd:8");
focusPoint[0] = QPoint(130,15);
focusPoint[1] = QPoint(815,60);

qDebug("HelpInfoWnd:9");
QString path = QString(QChar(index/10 + '0')) + QString(QChar(index%10 + '0')) + ".html";
openHelpFile(path);

qDebug("HelpInfoWnd:10");
QDir d(HelpPath);
d.setNameFilter(QString("*.html"));
helpNum = d.count()-1;

qDebug("HelpInfoWnd:11");
QString pageStr;
pageStr.sprintf("%d",index);
helpIndex->setText(pageStr);
helpIndex->home(true);

qDebug("HelpInfoWnd:12");
connect(helpIndex,SIGNAL( returnPressed() ),this,SLOT( goToHtml() ));
connect(helpIndex,SIGNAL( IGetFocus(bool) ),this,SLOT( showFocusAll(bool) ));

qDebug("HelpInfoWnd:13");
helpIndex->setFocus();

qDebug("HelpInfoWnd:14");
if(index) helpBrowser->setFocus();

qDebug("HelpInfoWnd:15");
languageChange();

qDebug("HelpInfoWnd:16");
}


qDebug是我加的调试代码,程序运行到qDebug("HelpInfoWnd:5");就停止了。
回复