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
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 !
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?
Re: QAxBase exception signal
thank you so much for your answer !!!!
Quote:
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 ...
Quote:
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)
Quote:
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.
Quote:
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 :
Code:
_xl(NULL),_workBooks(NULL)
{
// QObject::connect(_xl,SIGNAL(exception(int,QString,QString,QString)),
// this,SLOT(saveLastError(int,QString,QString,QString)));
setVisible(false);
_workBooks = _xl->querySubObject("Workbooks");
}
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 :
Code:
book->saveAs("Not*saveable");
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, ...")
Re: QAxBase exception signal
Sorry, i should have made a really simpler example (still complete and compilable):
project file, let's say "AxExcel.pro"
Code:
QT += core gui
TARGET = TestAxExcel
TEMPLATE = app
CONFIG += qaxcontainer
SOURCES += main.cpp
HEADERS += exceptreceiver.h
file exceptreceiver.h :
Code:
#ifndef EXCEPTRECEIVER_H
#define EXCEPTRECEIVER_H
#include <QObject>
#include <QDebug>
class ExceptReceiver
: public QObject{
Q_OBJECT
public:
public slots:
{
qDebug()<<errorCode<<source<<description<<help;
}
};
#endif // EXCEPTRECEIVER_H
file main.cpp :
Code:
#include <QApplication>
#include <QAxObject>
#include "exceptreceiver.h"
int main(int argc, char *argv[])
{
ExceptReceiver er;
if(QAxObject *wbs
= xlObj.
querySubObject("Workbooks")) {
if(QAxObject *workbook
= wbs
->querySubObject
("Add()")) {
workbook->dynamicCall("SaveAs(const QString &)","not*saveable");
delete workbook;
}
delete wbs;
}
return 0;
}
Console output when running this program (in french but it shouldn't be important) :
Code:
QAxBase: Error calling IDispatch member SaveAs
: Exception thrown by server
Code : 1004
Source : Microsoft Excel
Description: Fichier inaccessible. Essayez l'une des op?rations suivantes?:
? V?rifiez que le dossier sp?cifi? existe.
? V?rifiez que le dossier dans lequel se trouve le fichier n'est pas en lecture seule.
? V?rifiez que le nom du fichier ne comporte les caract?res suivants: | < > ? [ ] : ni *
? V?rifiez que le nom du fichier ou du chemin ne d?passe pas 218 caract?res.
Help : xlmain11.chm
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...
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 ...
Re: QAxBase exception signal
There is my code, It maybe help.
Code:
if (!xlObj->isNull())
{
xlObj->blockSignals(false);//<------- important
connect(xlObj,
SIGNAL(signal(QString,
int,
void*)),
SLOT(signal(QString,
int,
void*)));
}
In .h file
Code:
public Q_SLOTS:
void signal(const QString& name, int argc, void* argv);
in .cpp file
Code:
void XXXXX::signal(const QString& name, int argc, void* argv)
{
VARIANTARG *params = (VARIANTARG*)argv;
if (name.startsWith("BeforeNavigate2("))
{
IDispatch *pDisp = params[argc - 1].pdispVal;
VARIANTARG URL = *params[argc - 2].pvarVal;
VARIANTARG Flags = *params[argc - 3].pvarVal;
VARIANTARG TargetFrameName = *params[argc - 4].pvarVal;
VARIANTARG PostData = *params[argc - 5].pvarVal;
VARIANTARG Headers = *params[argc - 6].pvarVal;
bool *Cancel = params[argc - 7].pboolVal;
}
}