Congratulations to our 2022 Qt Champions!

Sending and receiving data or variables value from a project to other project.(Not dialog)

  • Hi everyone! For a start, I have a dialog that is ready to receive and display data/variables. One way to receive/display that I know is to key in the variables values in the header file in the same Qt application/dialog/project. (Not sure if its even the right method to begin). Thus I started to ponder, what if I want to send these variable values from another application/dialog/project (Not under the same project file, which utilise signals and slots) .

    For an instance, I have B(Receiving) . Thus, how do I send variables from A (with internet or without internet)? My aim is to make a dialog that solely receive and a totally separate dialog (not interlinked with the first) to send. Thank you and sorry if I got the terms all messed up.

  • Moderators

    There are many ways in which you can send data from one application to another.

    These include:

    • QtRemoteObjects
    • using network (QTcpSocket, QUdpSocket, maybe QNetworkAccessManager if one of your app exposes HTTP content)
    • using network via localhost (so you don't need 2 separate PCs for this, you can communicate within the same machine)
    • DBus
    • Bluetooth
    • etc.

    In order to send and receive the data, you can pack and unpack it using:

    • QDataStream
    • QJson
    • QXml* classes
    • ProtoBuf

  • @sierdzio Hi, sorry for the late reply and thank you for your reply. I am looking at 3rd point where you said "using network via localhost....". Is there any example for this? I am interested to try with 2 different PC and within the same PC.

  • Lifetime Qt Champion

    @Faruq It's same as point 2 but if on same machine you simply use as IP...

  • @jsulm alright, thanks to you and everyone. will ask again if I encounter any problem.

Log in to reply