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. AXIS camera SDK with QVariant problem : cannot access private member declared in class 'QVariant'
QtWS25 Last Chance

AXIS camera SDK with QVariant problem : cannot access private member declared in class 'QVariant'

Scheduled Pinned Locked Moved General and Desktop
9 Posts 3 Posters 4.1k Views
  • 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.
  • S Offline
    S Offline
    szysagittarius
    wrote on last edited by
    #1

    Hey, guys,

    I am new here, I am playing with AXIS network camera using its SDK based on QT. I want to use its GetCurrentImage function to get the Image.

    Below is the syntax of GetCurrentImage from AXIS SDK.

    GetCurrentImage
    Syntax
    HRESULT GetCurrentImage(int theFormat, [C++]
    VARIANT* theBuffer,
    LONG* theBufferSize
    );
    Parameters
    theFormat
    Identifier specifiying the format of the image data. Values available are: 0 = JPEG, 1 = BMP (defined in the AMC_IMAGE_FORMAT enum in the type library).

    theBuffer
    The buffer where the image data is returned.

    theBufferSize
    Size of the image data buffer returned.

    It looks like assigning the “theBuffer” field passing by reference, like the format below:
    @
    var* var;

    getCurrentImage(var){ // object-> dynamicallcall(“getCurrentImage(var)”)

    var = … // which can not be seen by us, because we are using dynamiccall to call the method in AXIS SDK
    }

    @

    So I choose QVariant to do that

    (1) In the .h file under public declaration,
    @
    QVariant* MediaBuffer;
    long* MediaBufferSize;
    @

    (2) in the .cpp file
    I first tried
    @
    axWidget->dynamicCall("GetCurrentImage(int, QVariant*, long*)",0,MediaBuffer, MediaBufferSize);
    @

    then I got the error report twice:

    error: C2248: 'QVariant::QVariant' : cannot access private member declared in class 'QVariant'
    e:\qt\4.8.5\src\corelib\kernel\qvariant.h:429: see declaration of 'QVariant::QVariant'
    e:\qt\4.8.5\src\corelib\kernel\qvariant.h:93: see declaration of 'QVariant'
    error: C2248: 'QVariant::QVariant' : cannot access private member declared in class 'QVariant'
    e:\qt\4.8.5\src\corelib\kernel\qvariant.h:429: see declaration of 'QVariant::QVariant'
    e:\qt\4.8.5\src\corelib\kernel\qvariant.h:93: see declaration of 'QVariant'

    in the second time, I tried
    @
    QList<QVariant> varList;
    varList << 0 << MediaBuffer << MediaBufferSize; // error report place
    axWidget->dynamicCall("GetCurrentImage(int, QVariant*, long*)",varList);
    axWidget->dynamicCall("GetCurrentImage(QList<QVariant>)",varList); // the same error report--
    @

    I got the same error report

    Looking deeper at the qvariant.h,
    In line 429 it is
    @
    private:
    // force compile error, prevent QVariant(bool) to be called
    inline QVariant(void *) { Q_ASSERT(false); } // line 429
    @

    in line 93
    it is
    @
    class Q_CORE_EXPORT QVariant
    @

    which I do not list all stuff here.

    It seems the problem of the usage of QVariant up to now, but I do not know how to fix it.

    Could you guys give me some suggestions?

    My environment is
    Qt 4.8.5
    Qtcreator 3.1.0
    Win 8
    AXIS Media Control API 6.30

    Many thanks,
    szysagittarius

    1 Reply Last reply
    0
    • hskoglundH Offline
      hskoglundH Offline
      hskoglund
      wrote on last edited by
      #2

      Hi, just a guess but your class that does the dynamicCalls, does it inherit from QObject?

      1 Reply Last reply
      0
      • S Offline
        S Offline
        szysagittarius
        wrote on last edited by
        #3

        Yes, there is QAxWidget in my code and it is inherited from QObject and QAxBase

        [quote author="hskoglund" date="1399662517"]Hi, just a guess but your class that does the dynamicCalls, does it inherit from QObject?
        [/quote]

        1 Reply Last reply
        0
        • hskoglundH Offline
          hskoglundH Offline
          hskoglund
          wrote on last edited by
          #4

          Ok, just looked closer at your source, QVariant* is not kosher: i.e. try change
          @
          QVariant* MediaBuffer;
          long* MediaBufferSize;
          @
          to
          @
          QVariant MediaBuffer;
          long* MediaBufferSize;
          @

          1 Reply Last reply
          0
          • S Offline
            S Offline
            szysagittarius
            wrote on last edited by
            #5

            No, that doesnot work, my friend. Because the mediaBuffer field can only be assigned through passing by reference when dynamiccall the outside function getCurrentImage, and pass the pointer of the MediaBuffer into the method in this case

            I am just suspecting whether it has something wrong with the usage of QVariant in QList, but I've already checked that it is not the initialization problem

            [quote author="hskoglund" date="1399669334"]Ok, just looked closer at your source, QVariant* is not kosher: i.e. try change
            @
            QVariant* MediaBuffer;
            long* MediaBufferSize;
            @
            to
            @
            QVariant MediaBuffer;
            long* MediaBufferSize;
            @
            [/quote]

            1 Reply Last reply
            0
            • hskoglundH Offline
              hskoglundH Offline
              hskoglund
              wrote on last edited by
              #6

              Aha, I thought of the compilation error, but if you need to pass by reference, try:
              @
              QVariant& MediaBuffer;
              long* MediaBufferSize;
              @
              (note: for the compiler to be happy you need to assign something to the reference QVariant as well).

              1 Reply Last reply
              0
              • S Offline
                S Offline
                szysagittarius
                wrote on last edited by
                #7

                I just filed my code and share it on github in the link below
                https://github.com/szysagittarius/AxisGetCurrentImageUsingQt/tree/master

                except the getCurrentImage function can not work properly, other functions works fine.

                you can play with this code after installing the AXIS Media Control sdk, which only need few second to install them
                below is the address of AXIS Media Control sdk,

                http://www.axis.com/techsup/cam_servers/dev/activex.htm

                the function document is under the doc in the installing directory (..\AXIS Media Control SDK\doc)

                If you have any suggestion after playing with this code, we can discuss here

                [quote author="hskoglund" date="1399677556"]Aha, I thought of the compilation error, but if you need to pass by reference, try:
                @
                QVariant& MediaBuffer;
                long* MediaBufferSize;
                @
                (note: for the compiler to be happy you need to assign something to the reference QVariant as well).[/quote]

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  szysagittarius
                  wrote on last edited by
                  #8

                  I want to update my knowledge of dynamicCall function

                  I use Qt getDocument function to get the AXIS document from AXIS COM component, which describes the exact way how to call every function of AXIS media control using Qt, and it says it did should use dynamicCall to assgin MediaBuffer and MediabufferSize these two local variables.

                  @
                  void GetCurrentImage (int theFormat, QVariant& theBuffer, int& theBufferSize) [slot]
                  get the current image
                  Connect a signal to this slot:
                  QObject::connect(sender, SIGNAL(someSignal(int, QVariant&, int&)), object, SLOT(GetCurrentImage(int, QVariant&, int&)));

                  Or call the function directly:
                  QVariantList params = ...
                  object->dynamicCall("GetCurrentImage(int, QVariant&, int&)", params);
                  @

                  So the code can be written like this

                  @
                  QVariant MediaBuffer;
                  long MediaBufferSize;
                  QList<QVariant> varList;
                  varList << 0 << MediaBuffer << MediaBufferSize;

                  axWidget->dynamicCall("GetCurrentImage(int, QVariant&, long&)",varList);
                  @
                  this can solve the problem of error report"can not access to the private member in class QVariant", because QVariant can not accpet address type.

                  However, even I follow what the document says on how to use dynamicCall to call this GetCurrentImage function, it will still report Bad parameter count or Exception thrown by server, and can not have these two local variables assigned.

                  example 1:
                  if I use

                  @
                  axWidget->dynamicCall("GetCurrentImage(int, QVariant&, int&)",0,MediaBuffer,MediaBufferSize);
                  @

                  it will report
                  @
                  /QAxBase: Error calling IDispatch member GetCurrentImage: Bad parameter count
                  @

                  example 2

                  if I use

                  @
                  QList<QVariant> varList;
                  varList << 0 << MediaBuffer << MediaBufferSize;
                  axWidget->dynamicCall("GetCurrentImage(int, QVariant&, long&)",varList);
                  @

                  it will report
                  @
                  IDispatch member GetCurrentImage: Exception thrown by server
                  Code : 16389
                  Source :
                  Description:
                  Help :
                  Connect to the exception(int,QString,QString,QString) signal to catch this exception
                  @
                  It seems that the second example's error report cover the first one, since these two local variables still not get assigned yet, my guess is the parameter type still mismatched.

                  What do you think of this bizarre outcome, my friend :)

                  I updated my problem code and uploaded it on github, if you have interest, you can play with it.
                  https://github.com/szysagittarius/AxisGetCurrentImageUsingQt

                  Best Regards

                  [quote author="hskoglund" date="1399677556"]Aha, I thought of the compilation error, but if you need to pass by reference, try:
                  @
                  QVariant& MediaBuffer;
                  long* MediaBufferSize;
                  @
                  (note: for the compiler to be happy you need to assign something to the reference QVariant as well).[/quote]

                  L 1 Reply Last reply
                  0
                  • S szysagittarius

                    I want to update my knowledge of dynamicCall function

                    I use Qt getDocument function to get the AXIS document from AXIS COM component, which describes the exact way how to call every function of AXIS media control using Qt, and it says it did should use dynamicCall to assgin MediaBuffer and MediabufferSize these two local variables.

                    @
                    void GetCurrentImage (int theFormat, QVariant& theBuffer, int& theBufferSize) [slot]
                    get the current image
                    Connect a signal to this slot:
                    QObject::connect(sender, SIGNAL(someSignal(int, QVariant&, int&)), object, SLOT(GetCurrentImage(int, QVariant&, int&)));

                    Or call the function directly:
                    QVariantList params = ...
                    object->dynamicCall("GetCurrentImage(int, QVariant&, int&)", params);
                    @

                    So the code can be written like this

                    @
                    QVariant MediaBuffer;
                    long MediaBufferSize;
                    QList<QVariant> varList;
                    varList << 0 << MediaBuffer << MediaBufferSize;

                    axWidget->dynamicCall("GetCurrentImage(int, QVariant&, long&)",varList);
                    @
                    this can solve the problem of error report"can not access to the private member in class QVariant", because QVariant can not accpet address type.

                    However, even I follow what the document says on how to use dynamicCall to call this GetCurrentImage function, it will still report Bad parameter count or Exception thrown by server, and can not have these two local variables assigned.

                    example 1:
                    if I use

                    @
                    axWidget->dynamicCall("GetCurrentImage(int, QVariant&, int&)",0,MediaBuffer,MediaBufferSize);
                    @

                    it will report
                    @
                    /QAxBase: Error calling IDispatch member GetCurrentImage: Bad parameter count
                    @

                    example 2

                    if I use

                    @
                    QList<QVariant> varList;
                    varList << 0 << MediaBuffer << MediaBufferSize;
                    axWidget->dynamicCall("GetCurrentImage(int, QVariant&, long&)",varList);
                    @

                    it will report
                    @
                    IDispatch member GetCurrentImage: Exception thrown by server
                    Code : 16389
                    Source :
                    Description:
                    Help :
                    Connect to the exception(int,QString,QString,QString) signal to catch this exception
                    @
                    It seems that the second example's error report cover the first one, since these two local variables still not get assigned yet, my guess is the parameter type still mismatched.

                    What do you think of this bizarre outcome, my friend :)

                    I updated my problem code and uploaded it on github, if you have interest, you can play with it.
                    https://github.com/szysagittarius/AxisGetCurrentImageUsingQt

                    Best Regards

                    [quote author="hskoglund" date="1399677556"]Aha, I thought of the compilation error, but if you need to pass by reference, try:
                    @
                    QVariant& MediaBuffer;
                    long* MediaBufferSize;
                    @
                    (note: for the compiler to be happy you need to assign something to the reference QVariant as well).[/quote]

                    L Offline
                    L Offline
                    longxian
                    wrote on last edited by
                    #9

                    @szysagittarius Did you have solved this problem? I have the same problem using Qt to open axis camera

                    1 Reply Last reply
                    0

                    • Login

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