Results 1 to 5 of 5

Thread: autocomplete for typedef functions does not work

  1. #1
    Join Date
    Nov 2014
    Posts
    5
    Qt products
    Qt5
    Platforms
    Windows

    Question autocomplete for typedef functions does not work

    Hey guys,

    lets say this up front: I'm a complete qt-newbie and this is my first QT Project.

    First some code (simplified):
    net.h :
    Qt Code:
    1. typedef HRESULT (__stdcall *pInitNet)(bool master, char* path);
    2. extern pInitNet initNet;
    To copy to clipboard, switch view to plain text mode 

    net.cpp
    Qt Code:
    1. pInitNet initNet;
    2. QLibrary *_netLib;
    3.  
    4. bool LoadDLL(QString pathToDLL = "") {
    5. if (_netLib != NULL)
    6. return false;
    7.  
    8. _netLib = new QLibrary(pathToDLL);
    9.  
    10. if (!_netLib->load())
    11. return false;
    12.  
    13. initNet = (pInitNet) _netLib->resolve("InitNet");
    14.  
    15. if (initNet)
    16. return true;
    17. else
    18. return false;
    19. }
    To copy to clipboard, switch view to plain text mode 

    main.cpp
    Qt Code:
    1. LoadDLL("libnet.dll");
    2. initNet( <-<-<-<-<-<-<-<-<- NO AUTOCOMPLETE
    To copy to clipboard, switch view to plain text mode 

    As you can see, I'm trying to load some dll function dynamically. So I define the dll functions, load them by QLibrary and assign them.
    It would be very unpleasant if I don't get autocomplete for these functions!
    Is there anything I'm doing wrong? Is this a bug if QT-creator?

    Some more details:
    Compiler-Kit: MinGW_32bit
    OS: Windows
    Version: QT 5.3.2 /QT Creator 3.2.2

    Thanks In advance!

    CU
    mts

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: autocomplete for typedef functions does not work

    As far as I understand it pInitNet is really a pointer type thus Creator will not treat it as a function (even though we know it is a function).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Nov 2014
    Posts
    5
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: autocomplete for typedef functions does not work

    Is there another way to load dll functions dynamically and make them usable by other classes?

    Anyway, the fact that I have cannot use function pointers without forgoing autocomplete is quite disappointing...

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: autocomplete for typedef functions does not work

    You can always setup a class containing methods with signatures similar to the functions you load and have the implementations call the real function.

    Something along the lines of:

    Qt Code:
    1. class Net {
    2. public:
    3. Net() {
    4. // ...
    5. m_initNet = _netLib->resolve("InitNet");
    6. }
    7. HRESULT initNet(bool a, char *b) { m_initNet(a, b); }
    8. private:
    9. pInitNet m_initNet;
    10. };
    11.  
    12. // ...
    13.  
    14. Net net;
    15. net.initNet(true, "...");
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Nov 2014
    Posts
    5
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: autocomplete for typedef functions does not work

    That what I thought and how I have solved it now.

    Thanks for your help anyway!

Similar Threads

  1. Replies: 1
    Last Post: 30th March 2018, 08:44
  2. Qt Creator using and autocomplete
    By pan in forum Qt Tools
    Replies: 1
    Last Post: 19th September 2011, 13:58
  3. how to do autocomplete with qt
    By wookoon in forum Newbie
    Replies: 3
    Last Post: 19th March 2011, 07:13
  4. Qt creator autocomplete
    By Stramonium in forum Qt Tools
    Replies: 4
    Last Post: 15th January 2011, 18:44
  5. QComboBox autocomplete
    By aekilic in forum Qt Programming
    Replies: 14
    Last Post: 13th May 2009, 16:23

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.