Results 1 to 4 of 4

Thread: ActiveQT (QAxObject) questions

  1. #1
    Join Date
    Sep 2010
    Posts
    14
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default ActiveQT (QAxObject) questions

    I've run into a couple of problems working with QAxObjects:
    1) I can't figure out how to access the 'member constants' of a QAxObject. I've dumped out (specifically accessing Excel). I've run the generateDocumentation() on my QAxObject, and I can see all the constants and their values, however I'm not sure how to actually query their value at run-time (in case they differ from version to version of excel say). Below are a few methods I've tried:
    Qt Code:
    1. QAxObject *excel = new QAxObject("Excel.Application",0);
    2. //attempt 1
    3. int num = excel->property("xlAll").toInt(); //from documentation, should have value of -4104
    4. //attempt 2
    5. int num = excel->querySubObject("xlAll").asVariant().toInt()
    To copy to clipboard, switch view to plain text mode 

    2) How do you pass an ignored value to a function when calling '->querySubObject()'? Some functions will have optional parameters, but will expect a void value for any parameters you wish to ignore. A specific example is below:
    For excel, if you want to add a worksheet to the end of the list of sheets, you call 'add(QVariant before, QVariant after)', where the before should be null if you want to use the 'after'. Apparently in C# you would use a value of 'Type.Missing', however I can not find the equivalent with QVariant.

    Thanks.

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: ActiveQT (QAxObject) questions

    I don't know about 1), but for 2) - have you tried to use an invalid QVariant (QVariant()) ?

  3. #3
    Join Date
    Sep 2010
    Posts
    14
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: ActiveQT (QAxObject) questions

    Yep, tried that as it seemed the logical step. However the QAxBase throws up an error:
    QAxBase: Error calling IDispatch member Add: Exception thrown by server
    Code : 1004
    Source : Microsoft Office Excel
    Description: Unable to get the Add property of the Sheets class
    Help : C:\Program Files (x86)\Microsoft Office\Office12\1033\XLMAIN11.CHM
    Connect to the exception(int,QString,QString,QString) signal to catch this exception

  4. #4
    Join Date
    Sep 2010
    Posts
    14
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: ActiveQT (QAxObject) questions

    Found a work around to access the 'Constants'. Ended up just making a function which strips out the constants from the QAxObject (thru the 'generateDocumenation') and stores them in a QHash. Not super elegant, but workable, and a lot faster then I originally thought it would be. Of course it is prone to having issues in future releases of QT, if they for some reason change the formatting that 'generateDocumentation' produces.

    As for making a default parameter... so far no dice. Seems strange that no-one has used ActiveQT and a member function which requires the use of a 'Type.Missing' variant as a place holder. So far I've managed to work around it, but again not the prettiest solution. For instance if you want to add a worksheet onto the end of a workbook, you have to call 'Add(before,after)', where 'before' would be the sheet to insert before (use a 'Type.Missing' variant if you will use the 'after' item), and 'after' would be the sheet to add it after. Basically I had to duplicate the last sheet (puts a copy before the last sheet), then run the add sheet passing the last sheet (which puts the new sheet before the last sheet), then finally remove the last sheet. Works, but it is sure a lot more steps!

Similar Threads

  1. Replies: 0
    Last Post: 2nd April 2011, 18:28
  2. Receiving COM event with QAxObject
    By ronald in forum Qt Programming
    Replies: 0
    Last Post: 7th January 2010, 20:38
  3. QAxObject Linker Error
    By ioannis in forum Qt Programming
    Replies: 2
    Last Post: 19th September 2008, 15:08
  4. QVariant to QAxObject*
    By QDrow in forum Qt Programming
    Replies: 1
    Last Post: 7th August 2008, 09:35
  5. QAxObject does not work anymore?
    By jh in forum Qt Programming
    Replies: 3
    Last Post: 6th July 2007, 22:04

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.