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. Need a few clarifications

Need a few clarifications

Scheduled Pinned Locked Moved General and Desktop
13 Posts 4 Posters 5.0k Views 1 Watching
  • 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
    sriharsha
    wrote on last edited by
    #3

    hi,
    ty for ur reply N3Roster.
    i found this program in the documentation. now here i understand in the below program that "avg" is the name of the function in the library but i am not able to understand what is "AvgFunction". is it any random function pointer or a specific interface name in the dll.
    thanks in advance.

    @typedef int (*AvgFunction)(int, int);

    AvgFunction avg = (AvgFunction) library->resolve("avg");
    if (avg)
    return avg(5, 8);
    else
    return -1;@

    1 Reply Last reply
    0
    • N Offline
      N Offline
      N3Roaster
      wrote on last edited by
      #4

      QLibrary::resolve(), as seen in its prototype, returns a void pointer. The first line provides a function pointer type that specifies the return type and argument types which should match the function you want to call through that pointer. In the second line, AvgFunction is the pointer type for the avg variable the pointer is assigned to while (AvgFunction) to the right of the assignment casts the pointer returned from resolve() to that type. There's nothing special about that name and it could be whatever makes sense in your application.

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

        hi,
        thankyou N3Roaster for the reply.i really appreciate it.
        i wrote a small snippet to access a function from the Apogee.dll file.Here is the code.
        @#include <QtCore/QCoreApplication>
        #include<stdio.h>
        #include<QLibrary.h>
        int main(int argc, char *argv[])
        { QCoreApplication a(argc, argv);
        QLibrary asd("Apogee");
        typedef bool (*ICamera2)(bool);
        ICamera2 d=(ICamera2) Apogee->resolve("ShowIODialog");
        bool ab;
        ab=asd.load();
        if(asd.isLoaded()==true)
        { printf("Loaded properly");
        if(d(true))
        {
        d(true);
        }
        else
        {
        printf("not possible");
        }
        }
        else
        {
        printf("not loaded");
        }
        return a.exec();
        } @
        but when i try to build my project it gives me an error '"Apogee" not declared in this scope' .thanks in advance.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          stukdev
          wrote on last edited by
          #6

          You have an error
          @
          typedef bool (*ICamera2)(bool);
          ICamera2 d=(ICamera2) Apogee->resolve("ShowIODialog");
          @

          maybe you want
          @
          typedef bool (*ICamera2)(bool);
          ICamera2 d=(ICamera2) asd->resolve("ShowIODialog");
          @
          [quote author="sriharsha" date="1298361645"]hi,
          thankyou N3Roaster for the reply.i really appreciate it.
          i wrote a small snippet to access a function from the Apogee.dll file.Here is the code.
          @#include <QtCore/QCoreApplication>
          #include<stdio.h>
          #include<QLibrary.h>
          int main(int argc, char *argv[])
          { QCoreApplication a(argc, argv);
          QLibrary asd("Apogee");
          typedef bool (*ICamera2)(bool);
          ICamera2 d=(ICamera2) Apogee->resolve("ShowIODialog");
          bool ab;
          ab=asd.load();
          if(asd.isLoaded()==true)
          { printf("Loaded properly");
          if(d(true))
          {
          d(true);
          }
          else
          {
          printf("not possible");
          }
          }
          else
          {
          printf("not loaded");
          }
          return a.exec();
          } @
          but when i try to build my project it gives me an error '"Apogee" not declared in this scope' .thanks in advance.[/quote]

          1 Reply Last reply
          0
          • N Offline
            N Offline
            N3Roaster
            wrote on last edited by
            #7

            Line 8 in your code. Change Apogee to asd.

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

              hi,
              Stuk and N3Roaster, thankyou for your replies.i am able to compile my program properly thanks to you.but wen i run i get an error message . being quite new to this i have no idea whats wrong with my coding.i am attaching a snapshot of the error.
              !http://c:/error.png(error snapshot)!
              if the snapshot is not seen then i will repost it.

              1 Reply Last reply
              0
              • S Offline
                S Offline
                stukdev
                wrote on last edited by
                #9

                Nothing seen.

                [quote author="sriharsha" date="1298368473"]hi,
                Stuk and N3Roaster, thankyou for your replies.i am able to compile my program properly thanks to you.but wen i run i get an error message . being quite new to this i have no idea whats wrong with my coding.i am attaching a snapshot of the error.
                !http://c:/error.png(error snapshot)!
                if the snapshot is not seen then i will repost it.[/quote]

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  sriharsha
                  wrote on last edited by
                  #10

                  hi,
                  sory about that . i have attached again . it wil be available this time.
                  !http://i.imgur.com/XdQ3K.png(Error Snapshot)!

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    goetz
                    wrote on last edited by
                    #11

                    A similar problem with Apogee was discusssed "here":http://developer.qt.nokia.com/forums/viewthread/3922.

                    Short story: You cannot resolve C++ symbols with QLibrary, only C symbols.

                    Longer story: you do not want to use QLibrary, but link to the DLL and use the header files provided for the DLL.

                    http://www.catb.org/~esr/faqs/smart-questions.html

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      sriharsha
                      wrote on last edited by
                      #12

                      hi,
                      ty volker for your reply. i tried to get the header files but it was not available so i was not able to that n has to resort to QLibrary.

                      1 Reply Last reply
                      0
                      • G Offline
                        G Offline
                        goetz
                        wrote on last edited by
                        #13

                        QLibrary is not a solution for C++ DLLs. You need the header files. Normally, those are provided in an SDK or the like.

                        http://www.catb.org/~esr/faqs/smart-questions.html

                        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