Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QAxObject problem
Forum Updated to NodeBB v4.3 + New Features

QAxObject problem

Scheduled Pinned Locked Moved General and Desktop
12 Posts 3 Posters 21.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jake007
    wrote on 18 Mar 2012, 13:35 last edited by
    #2

    SIGSEGV error is when you application tries to access RAM outside it's giver scope. OS force stops it.
    Can you paste code where qDebug shows error?


    Code is poetry

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Skyrim
      wrote on 18 Mar 2012, 14:46 last edited by
      #3

      Hi, its my code, I tested by Win7 + Word 2007 and works good )

      @
      QAxObject *word;
      QAxObject *doc;
      word = new QAxObject("Word.Application", this);
      word->setProperty("DisplayAlerts", false);
      word->setProperty("Visible", true);
      doc = word->querySubObject("Documents");
      doc->dynamicCall("Open(QVariant)", "d:\a15.doc");
      @

      1 Reply Last reply
      0
      • H Offline
        H Offline
        House15
        wrote on 18 Mar 2012, 16:27 last edited by
        #4

        [quote author="Jake007" date="1332077759"]SIGSEGV error is when you application tries to access RAM outside it's giver scope. OS force stops it.
        Can you paste code where qDebug shows error?[/quote]

        All ready did it. qDebug shows error on
        @
        QAxObject* WordApplication=new QAxObject("Word.Application"); // Создаю интерфейс к MSWord
        QAxObject* WordDocuments = WordApplication->querySubObject( "Documents()" );
        @

        SIGSEGV shows up on this row:
        @QAxObject* NewDocument = WordDocuments->querySubObject("Open(const QString&, bool)",FileNameAndPath, true);@

        [quote author="Skyrim" date="1332082018"]Hi, its my code, I tested by Win7 + Word 2007 and works good )

        @
        QAxObject *word;
        QAxObject *doc;
        word = new QAxObject("Word.Application", this);
        word->setProperty("DisplayAlerts", false);
        word->setProperty("Visible", true);
        doc = word->querySubObject("Documents");
        doc->dynamicCall("Open(QVariant)", "d:\a15.doc");
        @
        [/quote]

        Is really need to indicate path to file throw "\"? Can i also ask you some info about querySubObject? I tried to use generateDocumentation, but it failed. Have you example working code, or resource about this theme?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Skyrim
          wrote on 18 Mar 2012, 16:51 last edited by
          #5

          So you got it or not, and an example of what you are looking for.
          Here's an example creating a new document.
          @
          QAxObject *word;
          QAxObject *doc;
          word = new QAxObject("Word.Application", this);
          word->setProperty("DisplayAlerts", false);
          word->setProperty("Visible", true);
          doc = word->querySubObject("Documents");
          doc->dynamicCall("Add()");
          // doc = word->querySubObject("Documents")->dynamicCall("Add()"); // its working too
          @

          For help "this tread ":http://qt-project.org/forums/viewthread/1871/ about Excel

          1 Reply Last reply
          0
          • H Offline
            H Offline
            House15
            wrote on 18 Mar 2012, 16:52 last edited by
            #6

            Same error even on the code od Skyrim. Behavior of program are similar:
            @“QAxBase::setControl: requested control Word.Application could not be instantiated.
            QAxBase::dynamicCallHelper: Object is not initialized, or initialization failed.”@

            on steps:

            @@word = new QAxObject("Word.Application", this);@
            and
            @doc = word->querySubObject("Documents");@

            accordingly.

            My .pro file just in case:
            @
            QT += core

            QT -= gui

            TARGET = compare
            CONFIG += console
            CONFIG -= app_bundle qaxcontainer

            TEMPLATE = app

            LIBS += -lqaxcontainer

            SOURCES += main.cpp
            compare.cpp

            HEADERS +=
            compare.h

            OTHER_FILES +=@

            1 Reply Last reply
            0
            • S Offline
              S Offline
              Skyrim
              wrote on 18 Mar 2012, 16:56 last edited by
              #7

              ok in .pro file must be line

              @CONFIG += qaxcontainer@

              in .h file

              @
              #include <ActiveQt/qaxbase.h>
              #include <ActiveQt/qaxobject.h>
              @

              1 Reply Last reply
              0
              • H Offline
                H Offline
                House15
                wrote on 18 Mar 2012, 17:10 last edited by
                #8

                Done, but no effect.

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  Skyrim
                  wrote on 18 Mar 2012, 17:34 last edited by
                  #9

                  my .pro
                  @
                  QT += core gui
                  TARGET = andWord
                  TEMPLATE = app
                  SOURCES += main.cpp
                  mainwindow.cpp
                  HEADERS += mainwindow.h
                  FORMS += mainwindow.ui
                  CONFIG += qaxcontainer
                  @
                  my .h
                  @
                  #ifndef MAINWINDOW_H
                  #define MAINWINDOW_H
                  #include <QMainWindow>
                  #include <ActiveQt/qaxbase.h>
                  #include <ActiveQt/qaxobject.h>
                  namespace Ui {
                  class MainWindow;
                  }
                  class MainWindow : public QMainWindow
                  {
                  Q_OBJECT
                  public:
                  explicit MainWindow(QWidget *parent = 0);
                  ~MainWindow();
                  QAxObject *word;
                  QAxObject *doc;
                  private:
                  Ui::MainWindow *ui;
                  public slots:
                  void runWord();
                  void quitWord();
                  void setWordVisible(bool vis);
                  void addDoc();
                  };
                  #endif // MAINWINDOW_H
                  @

                  and .cpp
                  @
                  #include "mainwindow.h"
                  #include "ui_mainwindow.h"
                  MainWindow::MainWindow(QWidget *parent) :
                  QMainWindow(parent),
                  ui(new Ui::MainWindow)
                  {
                  ui->setupUi(this);
                  connect(ui->pushButton_run, SIGNAL(clicked()), this, SLOT(runWord()));
                  connect(ui->pushButton_quit, SIGNAL(clicked()), this, SLOT(quitWord()));
                  connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(addDoc()));
                  connect(ui->checkBox_visible, SIGNAL(clicked(bool)), this, SLOT(setWordVisible(bool)));
                  }
                  MainWindow::~MainWindow()
                  {
                  delete ui;
                  }
                  void MainWindow::runWord(){
                  word = new QAxObject("Word.Application", this);
                  word->setProperty("DisplayAlerts", false);
                  doc = word->querySubObject("Documents");
                  //doc->dynamicCall("Open(QVariant)", "d:\a15.doc");
                  }
                  void MainWindow::quitWord(){
                  doc->dynamicCall("Close()");
                  word->dynamicCall("Quit()");
                  }
                  void MainWindow::setWordVisible(bool vis){
                  word->setProperty("Visible", vis);
                  }
                  void MainWindow::addDoc(){
                  doc->dynamicCall("Add()");
                  }
                  @

                  1 Reply Last reply
                  0
                  • H Offline
                    H Offline
                    House15
                    wrote on 18 Mar 2012, 19:17 last edited by
                    #10

                    Qt show error on this row:
                    @word = new QAxObject("Word.Application", this);
                    @

                    Error message is:
                    @..\compare\compare.cpp:69: error: no matching function for call to 'QAxObject::QAxObject(const char [17], compare* const)'@

                    Maybe thing is in fact, what i have console application with added C++ class. How declare this method correctly in this case?

                    1 Reply Last reply
                    0
                    • H Offline
                      H Offline
                      House15
                      wrote on 20 Mar 2012, 11:11 last edited by
                      #11

                      Ok... after pasting code in solution with form and interface it's start work! Great! Now, there is a one problem, what still remains: i don't khown how to READ test from word file. I have founded a lot of examples inserting text in file, but no one, not ANY one don't wish to show me how QAxObject can READ text from file. If you can show it, i'll be very grateful.

                      1 Reply Last reply
                      0
                      • H Offline
                        H Offline
                        House15
                        wrote on 24 Mar 2012, 08:55 last edited by
                        #12

                        Ok, i have some progress - finally a i can read .doc files. That's great! But, unfortunately, there was another problem.

                        I have read about "linebreak" in .doc files, instead "\n". Linebreak denotes "\v". In beginning it works, and ,i started think, what problem was solved, but suddenly, linebreak stopped denotes. In QString it was just empty symbol (""), my condition on detecting empty string was ignored:

                        @
                        words = docA->querySubObject("Words");
                        QString textResult; //будущий результат
                        int countWord = words->dynamicCall("Count()").toInt(); //кол-во слов в тексте

                        QString testString;
                        int asciiCode;
                        //на самом деле он обманывает, считает зараза с пробелами :(
                        for (int a = 1; a <= countWord; a++)
                        {
                        if(testString.count()==1)
                        {
                        asciiCode=testString.toLocal8Bit().toInt();
                        textResult.append("\v");
                        }
                        else if(testString.isEmpty())
                        {-------//------------}
                        else if(testString.isNull())
                        {-------//------------}
                        else if(testString=="")
                        {-------//------------}
                        else if(testString=="\v")
                        {-------//------------}
                        else
                        textResult.append(words->querySubObject("Item(int)", a)->dynamicCall("Text()").toString());
                        testString.clear();
                        }
                        @

                        What the most intersting, that is ascii code of this empty symbol. It's =0. To tell the truth, i use integer number to detect the code, so I could be wrong.

                        Please, help somebody with this!

                        1 Reply Last reply
                        0

                        11/12

                        20 Mar 2012, 11:11

                        • Login

                        • Login or register to search.
                        11 out of 12
                        • First post
                          11/12
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved