免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3136 | 回复: 0
打印 上一主题 下一主题

QTextBrowser显示帮助系统的问题? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-12-27 16:32 |只看该作者 |倒序浏览
用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");就停止了。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP