Results 1 to 4 of 4

Thread: Can C functions send data to QT Slots in QT5.7 ?

  1. #1
    Join Date
    Jul 2017
    Posts
    13
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Can C functions send data to QT Slots in QT5.7 ?

    Dear Friends

    I want to do some trail work for proof of concept of my project.

    What I need is I have C source code that needs to communicate with QT slots. I am using QT Creator IDE and QT5.7.

    Qt Code:
    1. Ex
    2. unsigned int a[100]={ 25, 17 , 10, 6, -5 , -6, -8 , 10, ......... };
    To copy to clipboard, switch view to plain text mode 



    I am required to send this array data to QT GUI through Slots, from C source file to QT Slots is that possible?

    If possible please someone shows the code snippet in QT that will help me a lot


    Thanks

    vivekyuvan

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Can C functions send data to QT Slots in QT5.7 ?

    Qt is C++ and a slot is no different from any ordinary C++ function. There is no magic.

    Qt Code:
    1. class MyClass : public QObject
    2. {
    3. Q_OBJECT
    4.  
    5. // ...
    6.  
    7. public slots:
    8. void someSlot( size_t n, unsigned int * array )
    9. {
    10. // Do something with array
    11. }
    12.  
    13. // ...
    14. };
    15.  
    16. // Usage
    17.  
    18. MyClass myClass;
    19. unsigned int a[100]={ 25, 17 , 10, 6, -5 , -6, -8 , 10, ......... };
    20.  
    21. myClass.someSlot( 100, a );
    To copy to clipboard, switch view to plain text mode 

    In Qt 5, slots do not even have to be member functions, they can be any C++ function including lambdas.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Jul 2017
    Posts
    13
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Can C functions send data to QT Slots in QT5.7 ?

    Hi@d_stranz

    (Qt is C++ and a slot is no different from any ordinary C++ function. There is no magic. ) Yes I agree but what I want is

    I like to implement frontend alone in qt and backend is in C. The backend code was written in C its best to keep the code in C because its a driver code. so now my concern is can I communicate my driver code with frontend QT GUI?

    I just read out QDBUS Interprocess communication protocol it suits my application logic?

    Please give me any suggestion and show me the code snippet that will helpful


    Thanks
    vivek
    Last edited by vivekyuvan; 30th October 2018 at 05:30.

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Can C functions send data to QT Slots in QT5.7 ?

    show me the code snippet that will helpful
    We are not here to write your applications for you. There are many, many examples and tutorials that come with Qt, and many more on the Internet. I am sure there are some that use the Qt DBUS library. Study them.

    As I said, Qt is just a library written in C++, and you can call functions in any other C++ or C library from a C++ program. If you do not understand enough C / C++ to know how to call between C and C++ code, then you need to learn some basic programming skills first.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Can C functions send data to QT Slots in QT5.7 ?
    By vivekyuvan in forum Qt Programming
    Replies: 1
    Last Post: 29th October 2018, 15:16
  2. Replies: 16
    Last Post: 16th September 2013, 03:20
  3. Replies: 5
    Last Post: 17th November 2010, 17:29
  4. replacing signals and slots with callback functions
    By meena in forum Qt Programming
    Replies: 16
    Last Post: 23rd August 2010, 09:26
  5. Cannot call OpenCV 2.0 functions inside Qt slots
    By Asfer in forum Qt Programming
    Replies: 2
    Last Post: 19th February 2010, 11:48

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.