Results 1 to 5 of 5

Thread: Help displaying .doc format files in Qt application.

  1. #1
    Join Date
    May 2012
    Posts
    6
    Qt products
    Qt4
    Platforms
    Windows

    Question Help displaying .doc format files in Qt application.

    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.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Help displaying .doc format files in Qt application.

    Embed Microsoft Word using ActiveX.

  3. #3
    Join Date
    May 2012
    Posts
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Help displaying .doc format files in Qt application.

    Quote Originally Posted by ChrisW67 View Post
    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

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Help displaying .doc format files in Qt application.

    You might find some useful information here or here. 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.

  5. #5
    Join Date
    May 2012
    Posts
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Help displaying .doc format files in Qt application.

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

    Qt Code:
    1. #include "mainwindow.h"
    2. #include "ui_mainwindow.h"
    3.  
    4. MainWindow::MainWindow(QWidget *parent) :
    5. QMainWindow(parent),
    6. ui(new Ui::MainWindow)
    7. {
    8. ui->setupUi(this);
    9. QAxObject* word = new QAxObject("Word.Application",this);
    10. word->setProperty("DisplayAlerts", false);
    11. QAxObject* document = word->querySubObject("Documents()");
    12. document->querySubObject("Open(const QString&)", "D:\\Qt\\ProjektInzOp\\AlaMaKota.doc");
    13.  
    14.  
    15. }
    16.  
    17. MainWindow::~MainWindow()
    18. {
    19. delete ui;
    20. }
    To copy to clipboard, switch view to plain text mode 

    Now I can't find where I can list off all commands I can use while writing
    Qt Code:
    1. querySubObject("Parameter()");
    To copy to clipboard, switch view to plain text mode 

    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...

    Qt Code:
    1. #include "mainwindow.h"
    2. #include "ui_mainwindow.h"
    3.  
    4. MainWindow::MainWindow(QWidget *parent) :
    5. QMainWindow(parent),
    6. ui(new Ui::MainWindow)
    7. {
    8. ui->setupUi(this);
    9. QAxObject* word = new QAxObject("Word.Application",this);
    10. word->setProperty("DisplayAlerts", false);
    11. QAxObject* document = word->querySubObject("Documents()");
    12. document->querySubObject("Open(const QString&)", "D:\\Qt\\ProjektInzOp\\AlaMaKota.doc");
    13.  
    14.  
    15. }
    16.  
    17. MainWindow::~MainWindow()
    18. {
    19. delete ui;
    20. }
    To copy to clipboard, switch view to plain text mode 

    Now I can't find where I can list off all commands I can use while writing
    Qt Code:
    1. querySubObject("Parameter()");
    To copy to clipboard, switch view to plain text mode 

    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 :
    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent) :
    2. QMainWindow(parent),
    3. ui(new Ui::MainWindow)
    4. {
    5. ui->setupUi(this);
    6.  
    7. QAxWidget* WordDocument=new QAxWidget ("Word.Document", this-> ui-> textEdit);
    8. WordDocument-> setGeometry (QRect (10, 10, 621, 471));
    9. WordDocument->setControl ("D:\\Qt\\ProjektInzOp\\AlaMaKota.doc");
    10. WordDocument-> show ();
    11. }
    To copy to clipboard, switch view to plain text mode 

    And that is all... 4 lines of code... Qt is amazing
    Last edited by notes90; 28th September 2012 at 23:43.

Similar Threads

  1. Replies: 0
    Last Post: 21st October 2011, 13:01
  2. QListView not displaying all directory files
    By been_1990 in forum Qt Programming
    Replies: 14
    Last Post: 8th May 2009, 02:00
  3. Replies: 0
    Last Post: 19th February 2009, 15:32
  4. Handling mac text format files - support?
    By bnilsson in forum Qt Programming
    Replies: 0
    Last Post: 29th March 2008, 13:10
  5. An Application Icon - .pxm format
    By slava in forum Qt Programming
    Replies: 7
    Last Post: 18th February 2008, 11:00

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.