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. Constructor Initialization Fails
Qt 6.11 is out! See what's new in the release blog

Constructor Initialization Fails

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 509 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.
  • T Offline
    T Offline
    Tharma
    wrote on last edited by
    #1

    Hi, I am new to Qt/QtCreator world - I have been traditionally on Visual Studio. But seeing the kind of dynamism in the world, I was so excited learning what is what. Finally, I thought of doing a simple porting stuff from VS to Qt way. I failed and spent many days without any productivity. But what I am doing is damn simple.

    Here is what I used to do in VS2017 -

    class MyApiClient 
    {
    private:
        CManagerFactory   m_factory;
        CManagerInterface *m_manager;
    public:
    	MyApiClient() : m_factory("mymanapi64.dll"), m_manager(NULL)
    	{
    	   // constructor code
    	}
    

    When I tried it on Qt it did not work... and try many different ways like -

    I tried this
    I played around with QLibrary. Though my DLL gets loaded successfully using QLibrary Library(xxxx.dll).

        QLibrary library("C:/xx/MyWorkspace/Qt/mymanapi64.dll");
        if (!library.load()) {
          qDebug() << library.errorString();
        }
        else {
          qDebug() << "It loaded successfully";     // <- I get this message!!
    	 }
    

    BUT.... i do not know how to get the class member (m_factory) initialized using QLibrary in the similar way that I could do it in VS .

    Note This is a 3rd party .dll and along with that i have only a header and no libraries. I need to get the CManagerFactory instance, and start working on that. But I am stuck at this... you would not believe me, I wasted 20+ hours only this :(

    For Qt experts, maybe this could be a cake-walk. I would really appreciate if someone could throw lights on this.

    Thanks,
    Tharma

    aha_1980A 1 Reply Last reply
    0
    • T Tharma

      Hi, I am new to Qt/QtCreator world - I have been traditionally on Visual Studio. But seeing the kind of dynamism in the world, I was so excited learning what is what. Finally, I thought of doing a simple porting stuff from VS to Qt way. I failed and spent many days without any productivity. But what I am doing is damn simple.

      Here is what I used to do in VS2017 -

      class MyApiClient 
      {
      private:
          CManagerFactory   m_factory;
          CManagerInterface *m_manager;
      public:
      	MyApiClient() : m_factory("mymanapi64.dll"), m_manager(NULL)
      	{
      	   // constructor code
      	}
      

      When I tried it on Qt it did not work... and try many different ways like -

      I tried this
      I played around with QLibrary. Though my DLL gets loaded successfully using QLibrary Library(xxxx.dll).

          QLibrary library("C:/xx/MyWorkspace/Qt/mymanapi64.dll");
          if (!library.load()) {
            qDebug() << library.errorString();
          }
          else {
            qDebug() << "It loaded successfully";     // <- I get this message!!
      	 }
      

      BUT.... i do not know how to get the class member (m_factory) initialized using QLibrary in the similar way that I could do it in VS .

      Note This is a 3rd party .dll and along with that i have only a header and no libraries. I need to get the CManagerFactory instance, and start working on that. But I am stuck at this... you would not believe me, I wasted 20+ hours only this :(

      For Qt experts, maybe this could be a cake-walk. I would really appreciate if someone could throw lights on this.

      Thanks,
      Tharma

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Tharma

      you need to use resolve and cast the result to your functions signature.

      That is pure C/C++ basic and nothing special to Qt. QLibrary uses Windows API LoadLibrary behind the scenes (and similar calls on other OS) but provides you a convenient API.

      Regards

      Qt has to stay free or it will die.

      1 Reply Last reply
      1

      • Login

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