Results 1 to 9 of 9

Thread: QAxBase exception signal

  1. #1
    Join Date
    Oct 2011
    Posts
    27
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question QAxBase exception signal

    Hi all,

    I'm using QAxBase objects (ms excel automation) and would like to connect the QAxBase::exception(int,QString,QString,QString) signal to manage errors but i can't ...

    So, i've opened "qaxbase.h" source code and found :
    Qt Code:
    1. #ifdef qdoc
    2. Q_SIGNALS:
    3. void signal(const QString&,int,void*);
    4. void propertyChanged(const QString&);
    5. void exception(int,const QString&,const QString&,const QString&);
    6. #endif
    To copy to clipboard, switch view to plain text mode 

    of course "qdoc" is not defined ... so, what am i missing ?

    I have hardly googled, read the docs, searched on this forum but i found nothing ...
    (I think there's no link between the "#define qdoc" in the code and the "QDoc" html doc generator tool, so googling on qdoc is'nt an easy task but maybe i'm wrong)

    I'm using qt4 (same results with 4.7.4 and 4.8.5)
    I've put "CONFIG += qaxcontainer" in my pro file and nothing more.
    My code compile and runs well ...

    Please give me an answer even if its stupid (i'm really good at stupid mistakes ) or a link to the answer i havn't been able to find.

    thanks in advance

  2. #2
    Join Date
    Oct 2011
    Posts
    27
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QAxBase exception signal

    a little up please ...

    I don't find how to edit my post, so, i continue it
    There's no answers, tell me if i'm doing anything wrong (am i violating forum rules ? maybe the bold text is provocating, i thought it would permit a faster read of my problem ... please just tell me)

    Anyway, another formulation of my problem would be :

    Why the signals of QAxBase object are declared within a "#ifdef qdoc" directive ?

    thanks again

  3. #3
    Join Date
    Oct 2011
    Posts
    27
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QAxBase exception signal

    another up ... (two weeks later, i can, can't i?)

    ok, let's assume the exception signal is just a joke and just exists in documentation but not in the code !
    it's just defined in qaxbase.h to generate documentation and make custommer trust active Qt is worth the bsd licence !

    please tell me i'm wrong and criticize my disrespectful behavior !

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

    Default Re: QAxBase exception signal

    Your lack of response could be because few people use ActiveQt, and fewer have tried to use your particular corner of it.

    Exactly how are you trying to connect?
    Are the unspecified errors at compile, link, program run time, or during ActiveX operations?
    What are the exact errors?
    Can you post a complete, small example that demonstrates the problem?

  5. #5
    Join Date
    Oct 2011
    Posts
    27
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QAxBase exception signal

    thank you so much for your answer !!!!

    Your lack of response could be because few people use ActiveQt, and fewer have tried to use your particular corner of it.
    I know that the good guys uses dumpcpptool. But, I'm not doing anything particular, just using a Qt class and connecting one of it signals to the slot of another Qt class ... nothing more than connecting the "clicked()" signal of a QPushButton ...

    Exactly how are you trying to connect?
    well, normally : connect(QAxObject *,SIGNAL(exception(int, QString, QString, QString), this, SLOT(myErrorHandleSlot(int, QString, QString, QString))
    but when typing, the autocompletion didn't work, so, I checked my includes and includepath, .... everything were OK. So , at last, I've gone to the qaxbase.h source code and found the exception signal defined within an #ifdef qdoc preprocessor statement ... so, of course, i cannot connect. I could let this connect line code, it will compile but during runtime i'll get an error like "no such signal ..." (using Qt4)

    Are the unspecified errors at compile, link, program run time, or during ActiveX operations?
    What are the exact errors?
    The errors are during ActiveX operations but are normal errors which can occur using excel, for instance, trying to write two cells within one, ...
    my code compile and runs well, but, when an operation fails, an explicit message outputs on console and says "connect to the exception signal to retrieve these message"

    As I can't connect to this signal, I just can know that the operation fails but not why and i can't show an explicit message to the user.

    Can you post a complete, small example that demonstrates the problem?
    Of course : http://www.itest.fr/Download/AxExcel.zip

    The connection with exception signal is in xlapp.cpp file, line 38 :

    Qt Code:
    1. XLApp::XLApp(QObject *parent) :
    2. QObject(parent),
    3. _xl(NULL),_workBooks(NULL)
    4. {
    5. _xl = new QAxWidget("Excel.Application");
    6.  
    7. // QObject::connect(_xl,SIGNAL(exception(int,QString,QString,QString)),
    8. // this,SLOT(saveLastError(int,QString,QString,QString)));
    9.  
    10. setVisible(false);
    11. _workBooks = _xl->querySubObject("Workbooks");
    12. }
    To copy to clipboard, switch view to plain text mode 

    Running the program should output an error message containing the informations of the exception signal i'd like to retrieve when executing the line 16 of main.cpp :

    Qt Code:
    1. book->saveAs("Not*saveable");
    To copy to clipboard, switch view to plain text mode 

    it should ouput these wonderfull lines :
    error code = 1004
    Source = Microsoft Excel
    Description = A really really good description but in french in my case ... (something like "file access error. Check the folder exists, ...")

  6. #6
    Join Date
    Oct 2011
    Posts
    27
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QAxBase exception signal

    Sorry, i should have made a really simpler example (still complete and compilable):

    project file, let's say "AxExcel.pro"
    Qt Code:
    1. QT += core gui
    2.  
    3. TARGET = TestAxExcel
    4. TEMPLATE = app
    5.  
    6. CONFIG += qaxcontainer
    7.  
    8. SOURCES += main.cpp
    9. HEADERS += exceptreceiver.h
    To copy to clipboard, switch view to plain text mode 

    file exceptreceiver.h :
    Qt Code:
    1. #ifndef EXCEPTRECEIVER_H
    2. #define EXCEPTRECEIVER_H
    3.  
    4. #include <QObject>
    5. #include <QDebug>
    6.  
    7. class ExceptReceiver : public QObject
    8. {
    9. Q_OBJECT
    10. public:
    11. ExceptReceiver():QObject(){}
    12.  
    13. public slots:
    14. void debugError(int errorCode, QString source, QString description, QString help)
    15. {
    16. qDebug()<<errorCode<<source<<description<<help;
    17. }
    18. };
    19.  
    20.  
    21. #endif // EXCEPTRECEIVER_H
    To copy to clipboard, switch view to plain text mode 

    file main.cpp :
    Qt Code:
    1. #include <QApplication>
    2.  
    3. #include <QAxObject>
    4. #include "exceptreceiver.h"
    5.  
    6. int main(int argc, char *argv[])
    7. {
    8. QApplication a(argc, argv);
    9.  
    10. QAxObject xlObj("Excel.Application");
    11.  
    12. ExceptReceiver er;
    13. QObject::connect(&xlObj,SIGNAL(exception(int, QString, QString, QString)),
    14. &er,SLOT(debugError(int,QString,QString,QString)));
    15.  
    16. if(QAxObject *wbs = xlObj.querySubObject("Workbooks"))
    17. {
    18. if(QAxObject *workbook = wbs->querySubObject("Add()"))
    19. {
    20. workbook->dynamicCall("SaveAs(const QString &)","not*saveable");
    21. delete workbook;
    22. }
    23. delete wbs;
    24. }
    25.  
    26. return 0;
    27. }
    To copy to clipboard, switch view to plain text mode 

    Console output when running this program (in french but it shouldn't be important) :
    Qt Code:
    1. QAxBase: Error calling IDispatch member SaveAs: Exception thrown by server
    2. Code : 1004
    3. Source : Microsoft Excel
    4. Description: Fichier inaccessible. Essayez l'une des op?rations suivantes?:
    5.  
    6. ? V?rifiez que le dossier sp?cifi? existe.
    7. ? V?rifiez que le dossier dans lequel se trouve le fichier n'est pas en lecture seule.
    8. ? V?rifiez que le nom du fichier ne comporte les caract?res suivants: | < > ? [ ] : ni *
    9. ? V?rifiez que le nom du fichier ou du chemin ne d?passe pas 218 caract?res.
    10. Help : xlmain11.chm
    11. Connect to the exception(int,QString,QString,QString) signal to catch this exception
    To copy to clipboard, switch view to plain text mode 
    Last edited by thomas@itest; 12th December 2013 at 14:17. Reason: added console output

  7. #7
    Join Date
    Sep 2015
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QAxBase exception signal

    damn...I hit the same problem to you.
    Have you fixed it buddy?Could you mind telling me how to slove it?
    thanks all...

  8. #8
    Join Date
    Oct 2011
    Posts
    27
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QAxBase exception signal

    No, I gave up with Qt ActiveX !
    Wrapping COM objects is not a huge work even if msdn documentation is a pain in the ...

  9. #9

    Default Re: QAxBase exception signal

    There is my code, It maybe help.
    Qt Code:
    1. QAxObject* xlObj = new QAxObject("Excel.Application");
    2.  
    3. if (!xlObj->isNull())
    4. {
    5. xlObj->blockSignals(false);//<------- important
    6. connect(xlObj, SIGNAL(signal(QString, int, void*)), SLOT(signal(QString, int, void*)));
    7. }
    To copy to clipboard, switch view to plain text mode 
    In .h file
    Qt Code:
    1. public Q_SLOTS:
    2. void signal(const QString& name, int argc, void* argv);
    To copy to clipboard, switch view to plain text mode 

    in .cpp file

    Qt Code:
    1. void XXXXX::signal(const QString& name, int argc, void* argv)
    2. {
    3. VARIANTARG *params = (VARIANTARG*)argv;
    4. if (name.startsWith("BeforeNavigate2("))
    5. {
    6. IDispatch *pDisp = params[argc - 1].pdispVal;
    7. VARIANTARG URL = *params[argc - 2].pvarVal;
    8. VARIANTARG Flags = *params[argc - 3].pvarVal;
    9. VARIANTARG TargetFrameName = *params[argc - 4].pvarVal;
    10. VARIANTARG PostData = *params[argc - 5].pvarVal;
    11. VARIANTARG Headers = *params[argc - 6].pvarVal;
    12. bool *Cancel = params[argc - 7].pboolVal;
    13. }
    14. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. How to avoid this exception?
    By Gokulnathvc in forum Newbie
    Replies: 3
    Last Post: 29th August 2012, 11:26
  2. use try cacth exception
    By jindoniit in forum Newbie
    Replies: 14
    Last Post: 31st August 2011, 07:47
  3. Unhandled Exception from DLL QT 4.6.0
    By qlarity_three in forum Newbie
    Replies: 2
    Last Post: 5th February 2010, 19:11
  4. exception mechanism
    By guchangyuan in forum Qt Programming
    Replies: 2
    Last Post: 10th August 2009, 04:57
  5. exception
    By AnithaRagupathy in forum Qt Programming
    Replies: 1
    Last Post: 14th November 2007, 09:59

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.