Better_Software_Header_MobileBetter_Software_Header_Web

Find what you need - explore our website and developer resources

KDSingleApplication: a class for single-instance policy applications

int main(int argc, char **argv)
{
    QApplication app(argc, argv);
    KDSingleApplication kdsa;
if (kdsa.isPrimaryInstance()) {
        /* primary: listen to messages */
        QObject::connect(&kdsa, &KDSingleApplication::messageReceived,
                         /* handle messages from the secondary instances */);
    } else {
        /* secondary: send message to the primary */
        kdsa.sendMessage("some message to the primary");

        /* quit */
        return 0;
    }

About KDAB


2 Comments

25 - Feb - 2021

Guilhem

25 - Feb - 2021

Giuseppe D'Angelo

GiuseppeD'Angelo

Giuseppe D’Angelo

Senior Software Engineer

Learn Modern C++

Learn more