PDA

View Full Version : Help displaying .doc format files in Qt application.



notes90
24th September 2012, 20:21
Hello,

As Its written in title, I want to display .doc file content in Qt application window. I read that QTextBrowser is opening only plain txt and html files.
Anyone have ideas how can I display doc files( MS Word 97-2000 files ) ? It's a part of my project and I dont have any idea how to get into it....

Any help would be appreciated,
notes.

ChrisW67
24th September 2012, 23:34
Embed Microsoft Word using ActiveX.

notes90
26th September 2012, 13:04
Embed Microsoft Word using ActiveX.
Any idea where to read about activeX in Qt ? Is there any tutorial or documentation out there ?
I found only this :http://doc.qt.digia.com/qt-maemo/activeqt.html
which didn't help a lot :(

d_stranz
26th September 2012, 17:29
You might find some useful information here (http://www.codeproject.com/Articles/3582/Word-Control-for-NET) or here (http://www.anupshinde.com/microsoft-word-in-dotnet). These examples are .NET based, but you should be able to substitute the Qt ActiveX container and ActiveX QWidget for the similar .NET container and window.

notes90
28th September 2012, 23:43
I've looked into QAxObjects and came up with this piece of code that opens ms word .doc file...


#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QAxObject* word = new QAxObject("Word.Application",this);
word->setProperty("DisplayAlerts", false);
QAxObject* document = word->querySubObject("Documents()");
document->querySubObject("Open(const QString&)", "D:\\Qt\\ProjektInzOp\\AlaMaKota.doc");


}

MainWindow::~MainWindow()
{
delete ui;
}


Now I can't find where I can list off all commands I can use while writing


querySubObject("Parameter()");


That list would help me a lot with planning how to get text, picutres ect.

I've looked into QAxObjects and came up with this piece of code that opens ms word .doc file...


#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QAxObject* word = new QAxObject("Word.Application",this);
word->setProperty("DisplayAlerts", false);
QAxObject* document = word->querySubObject("Documents()");
document->querySubObject("Open(const QString&)", "D:\\Qt\\ProjektInzOp\\AlaMaKota.doc");


}

MainWindow::~MainWindow()
{
delete ui;
}


Now I can't find where I can list off all commands I can use while writing


querySubObject("Parameter()");


That list would help me a lot with planning how to get text, picutres ect.

Added after 1 17 minutes:

Ok... Problem has been solved, thanks for help everyone :)

Solution was very simple :


MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);

QAxWidget* WordDocument=new QAxWidget ("Word.Document", this-> ui-> textEdit);
WordDocument-> setGeometry (QRect (10, 10, 621, 471));
WordDocument->setControl ("D:\\Qt\\ProjektInzOp\\AlaMaKota.doc");
WordDocument-> show ();
}

And that is all... 4 lines of code... Qt is amazing :D