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. [SOLVED] QOCIDriver handle from QVariant to void *

[SOLVED] QOCIDriver handle from QVariant to void *

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.5k 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.
  • G Offline
    G Offline
    Galbarad
    wrote on last edited by
    #1

    Hi all
    I have problem with getting OCI handle
    I try following code
    @QSqlDriver *driver = connect.driver(); // get pointer to driver
    QVariant h = driver->handle(); // get QVariant handle
    void *vh = h.value<void *>(); // in this point I\m receive 0 @

    this is part of QOCIDriver that return handle
    @
    QVariant QOCIDriver::handle() const
    {
    // d->env -pointer to OCIEnv ( type OCIEnv * )
    return QVariant::fromValue(d->env);
    }@

    How I can tear off my OCIEnv * from QVariant ?

    thank you

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      It returns 0 because the QVariant is of custom type OCIStmt* (declared in qsql_oci.cpp and also mentioned in the comment). Try:
      @
      OCIStmt handle = h.value<OCIStmt>();
      @

      1 Reply Last reply
      0
      • G Offline
        G Offline
        Galbarad
        wrote on last edited by
        #3

        Hi thank you for you reply, but OCIStmt return as handle in another class
        @QVariant QOCIResult::handle() const
        {
        return QVariant::fromValue(d->sql);
        }@

        QOCIDriver return OCIEnv *env;

        but even I try
        @OCIEnv *vhh = h.value<OCIEnv *>();@

        I receive compilation errors
        use of undefined type 'OCIEnv'
        Type argument of Q_DECLARE_METATYPE(T*) must be fully defined
        E:\Qt\Qt5.0.0\5.0.0\msvc2010\include\QtCore\qmetatype.h 464

        declaration type OCIEnv in oci.h
        @typedef struct OCIEnv OCIEnv; /* OCI environment handle */@

        as I read somewhere in Internet QVariant store not simple and not QObject values in void * so I suppose that I can take my value through
        @void *vh = h.value<void *>();@

        1 Reply Last reply
        0
        • G Offline
          G Offline
          Galbarad
          wrote on last edited by
          #4

          problem solved
          just use
          @QVariant QOCIDriver::handle() const
          {
          // d->env -pointer to OCIEnv ( type OCIEnv * )
          return QVariant::fromValue((void *)d->env);
          }@

          instead of

          @QVariant QOCIDriver::handle() const
          {
          // d->env -pointer to OCIEnv ( type OCIEnv * )
          return QVariant::fromValue(d->env);
          }@

          How I can add my own method into QOCIDriver??? for example getServerHandle?

          thanks

          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