C++ 如何使用QAxObject捕获/抛出错误

C++ 如何使用QAxObject捕获/抛出错误,c++,excel,qt,try-catch,throw,C++,Excel,Qt,Try Catch,Throw,我想使用QAxObject处理Excel文件 我希望实现如下代码所示的初始化: QAxObject* excel;//excel pointer void initExcel(){ try { //if there excel process already running try to use it } //catch if it's not running catch() { try {

我想使用
QAxObject
处理Excel文件
我希望实现如下代码所示的初始化:

QAxObject* excel;//excel pointer

void initExcel(){
    try
    {
        //if there excel process already running try to use it
    }
    //catch if it's not running
    catch()
    {
        try 
        {
            excel = new QAxObject("Excel.Application");
        } 
        catch 
        {
            //meassge if excel not exist/can't start     
        }
    }
}

如何捕获/抛出QAxObject的错误?我试着用谷歌搜索它,但没有找到任何exapmlpe

要知道是否加载了ActiveX控件,应该使用setControl方法的结果。要捕获ActiveX控件的异常,应连接到异常信号

bool controlLoaded = axWidget->setControl("Word.Document");
if (!controlLoaded)
{
    // Message about control didn't load
}
else
{
    // Control loaded OK; connecting to catch exceptions from control
    connect(
        axWidget, 
        SIGNAL(exception(int, const QString &, const QString &, const QString &)), 
        this, 
        SLOT(onAxWidgetException(int, const QString &, const QString &, const QString &)));
}
谢谢,乡下人!:)我稍后会接受你的回答,好吗?恐怕今天我有些别的东西,明天我会检查你的溶液