QT加载office文件简单方法

本文档介绍了如何使用QT的COM组件来加载并显示Office文件,包括.docx, .doc, .xls, .xlsx等格式。通过创建QAxWidget对象并设置相关属性,可以实现在QT应用中直接嵌入并显示这些文件的内容。对于PPT文件,文档说明由于技术限制无法直接嵌入。" 103899664,5589275,SpringBoot:深入理解@Resource注解,"['Spring框架', '注解', '依赖管理']

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

记录下:

   QT 使用COM组件加载office的文件,使用需要安装MS office。WORD,EXCEL文件可以直接嵌入;PPT文件无法直接嵌入。能嵌入的同志望回复告知。下面描述了 加载;*.doc;*.docx;*.docm;*.xls;*.xlsx;*.xlsm;*.xlsb,*.ppt;*.pptx;*.pptm;*.txt;*.xml;这几种文件。源代码如下:

一:组件皮肤文件  utofficewidget.ui


<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>UTOfficeWidget</class>
 <widget class="QWidget" name="UTOfficeWidget">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>400</width>
    <height>300</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>UTOfficeWidget</string>
  </property>
  <layout class="QVBoxLayout" name="verticalLayout">
   <item>
    <widget class="QTextEdit" name="textEdit"/>
   </item>
  </layout>
 </widget>
 <layoutdefault spacing="6" margin="11"/>
 <resources/>
 <connections/>
</ui>
二:头文件  utofficewidget.h
#ifndef UTOFFICEWIDGET_H
#define UTOFFICEWIDGET_H
#include <QWidget>
#include<QAxObject>
#include<QAxWidget>
#include <QTextStream>
#include<QFile>
#include "ui_utofficewidget.h"
class UTOfficeWidget : public QWidget

评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值