Results 1 to 5 of 5

Thread: c++ library integration?

  1. #1
    Join Date
    Oct 2010
    Location
    Greece
    Posts
    3
    Thanks
    1

    Default c++ library integration?

    Hallo world!

    Let's get to the point. We are about to start working with the creation of an advanced GUI interfacing a big complicated C++ library.
    Our task is to represent every C++ routine as a module in the GUI and to enable users to make combinations of those module to produce a diferent output (depending on the modules combination) of the initial input.
    The question is this: can we do this efficiently, without interfere with the library's routines' code? Just use their output?
    And will those routines be compiled at once with the whole GUI project so we can feed them with data easily and check their outputs at any time?
    Are we gonna need any code as glue between GUI and library?

    Too many questions for a debute. Will come back with more

  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: c++ library integration?

    Quote Originally Posted by wabab View Post
    The question is this: can we do this efficiently, without interfere with the library's routines' code? Just use their output?
    And will those routines be compiled at once with the whole GUI project so we can feed them with data easily and check their outputs at any time?
    Are we gonna need any code as glue between GUI and library?
    It's hard to answer any of those questions without knowing how the library works and what it does.

    I can try to answer the last question -- you don't need any code to glue your library to Qt but it might be beneficial if you had a wrapper around your library to integrate it with Qt's API, especially its data structures and models.
    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
    Oct 2010
    Location
    Greece
    Posts
    3
    Thanks
    1

    Default Re: c++ library integration?

    Hi there...

    Quote Originally Posted by wysota View Post
    It's hard to answer any of those questions without knowing how the library works and what it does.
    The library is a series of pure C++ classes. Each class has a series of routines and each of them represents an electronic unit. It's a simulator. The user inputs the initial data (eg voltage, ...) and the routine produces the outcomes. I need to viualise this via a GUI. But C++ is not the ideal language for this. Here comes a simple routine example:

    Qt Code:
    1. generic_unit* specific_generic_unit(const int min, const int* volt, const double energy)
    2. {
    3. int i;
    4. if(min<=0)
    5. {
    6. printf("specific_generic_unit: problem.\n");
    7. exit(1);
    8. }
    9. int M=1<<min;
    10. double level=sqrt(energy);
    11. double* sR = new double[2*M];
    12.  
    13. double off=32.53253245435/M;
    14. for(i=0;i<M;i++)
    15. {
    16. sR[2*i] = level*cos(off*(1.+2.*i));
    17. sR[2*i+1] = level*sin(off*(1.+2.*i));
    18. }
    19. generic_unit* temp=new generic_unit;
    20. if (volt==(const int*)1)volt=[12,43,43,21];
    21.  
    22. temp->SetParameters(min,sR,volt,false);
    23.  
    24. delete[] sR;
    25. return temp;
    26. }
    To copy to clipboard, switch view to plain text mode 

    Have in mind that there will be multiple, different and complex type input and multiple output as well. I DON'T WANT TO INTERFERE with those routines' code. That's my critical question...Do I need something more than the Qt Suite. Won't it compile the whole thing, the C++ routines and the Qt gui code at the same project? I have no idea how to start at this point...how to connect my code with the GUI...Probably I haven't studied enough, or is this a Qt weakness?

    Quote Originally Posted by wysota View Post
    I can try to answer the last question -- you don't need any code to glue your library to Qt but it might be beneficial if you had a wrapper around your library to integrate it with Qt's API, especially its data structures and models.
    Some glue code? Beneficial coding is crucial as well. But if there is a need for glue code then we return to my first question about connecting directly Qt GUI with the C++ library at the sam Qt project. Are there any examples of such glue code?

  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: c++ library integration?

    Quote Originally Posted by wabab View Post
    Do I need something more than the Qt Suite.
    No.

    Won't it compile the whole thing, the C++ routines and the Qt gui code at the same project?
    It will. Unless you don't want it to -- then you can make your pure C++ part a library and just link to it from the part written using Qt.
    I have no idea how to start at this point...how to connect my code with the GUI...Probably I haven't studied enough, or is this a Qt weakness?
    You have not studied enough

    Some glue code? Beneficial coding is crucial as well. But if there is a need for glue code then we return to my first question about connecting directly Qt GUI with the C++ library at the sam Qt project. Are there any examples of such glue code?
    For instance if have a routine that outputs an array of elements, then it is beneficial to wrap it into Qt API (i.e. to return "QList<Element>" instead of "Element*") and maybe make it object oriented at the same time as currently your code looks more like C than C++.
    This is not something you have to do but Qt provides many routines (for instance "foreach" loop) that would be more efficient or simply would let your data be handled easier if the data conformed to Qt's API.

    Wow... not that I look at it, your code is completely C-ish and not a pretty one, too. What does this do?
    Qt Code:
    1. if (volt==(const int*)1)volt=[12,43,43,21];
    To copy to clipboard, switch view to plain text mode 
    Correct me if I'm wrong but this is an (incorrect, this condition will never return true) equivalent of:
    Qt Code:
    1. if (*volt==1) volt= ??? [12];// is this pure ANSI/C99 C++? What does the [] construction do here?
    To copy to clipboard, switch view to plain text mode 

    You should make your code more C++-ish... Sorry for going off-topic, I always want to correct the world...
    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. The following user says thank you to wysota for this useful post:

    wabab (8th October 2010)

  6. #5
    Join Date
    Oct 2010
    Location
    Greece
    Posts
    3
    Thanks
    1

    Post Re: c++ library integration?

    That's straightforward enough for me to go on. I guess I'll start some serious studying.

    One question though: I can probably make a simple type casting for such situations ("QList<Element>" instead of "Element*")....

    Quote Originally Posted by wysota View Post
    Wow... not that I look at it, your code is completely C-ish and not a pretty one, too. What does this do?
    Qt Code:
    1. if (volt==(const int*)1)volt=[12,43,43,21];
    To copy to clipboard, switch view to plain text mode 
    Correct me if I'm wrong but this is an (incorrect, this condition will never return true) equivalent of:
    Qt Code:
    1. if (*volt==1) volt= ??? [12];// is this pure ANSI/C99 C++? What does the [] construction do here?
    To copy to clipboard, switch view to plain text mode 

    You should make your code more C++-ish... Sorry for going off-topic, I always want to correct the world...
    Haha...you did actually looked at it. I was trying to present a "generalised" code so I changed var names and stuff. The one you were looking with horror at and you are completely right was actually a const array's element, so by rush I made a representation of the whole const array instead of a single element of it (array[2]---->[23,323,43,23,...]) Anyway that's not my code so feel free to say anything

    Let's sail on with this...

Similar Threads

  1. Replies: 7
    Last Post: 22nd December 2010, 08:13
  2. VS Integration
    By GrahamLabdon in forum Qt Programming
    Replies: 3
    Last Post: 25th March 2010, 08:06
  3. Replies: 4
    Last Post: 18th December 2009, 18:55
  4. Video processing library integration Qt4
    By tpieciak in forum Qt Programming
    Replies: 0
    Last Post: 5th December 2009, 17:37
  5. Eclipse Integration sans Integration
    By ChrisW67 in forum Qt Tools
    Replies: 3
    Last Post: 17th March 2009, 07:29

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.