Hi, last time I am trying to implement a Url protocol scheme, How it works ? Very simple, as first we need to register a url scheme in our system, to assign url address with our app and then we can send some message using web browser address bar.

Code to register url address

Qt Code:
  1. bool Settings::registerProtocol()
  2. {
  3. #ifdef Q_OS_WIN
  4. const QString urlScheme = "myapp";
  5. const QString appPath = QDir::toNativeSeparators(QCoreApplication::applicationFilePath());
  6. const QString regPath = QStringLiteral("HKEY_CURRENT_USER\\Software\\Classes\\") + urlScheme;
  7.  
  8. QScopedPointer<QSettings> reg(new QSettings(regPath, QSettings::NativeFormat));
  9.  
  10. reg->setValue(QStringLiteral("Default"), "download manager");
  11. reg->setValue(QStringLiteral("URL Protocol"), QString());
  12.  
  13. reg->beginGroup(QStringLiteral("DefaultIcon"));
  14. reg->setValue(QStringLiteral("Default"), QString("%1,1").arg(appPath));
  15. reg->endGroup();
  16.  
  17. reg->beginGroup(QStringLiteral("shell"));
  18. reg->beginGroup(QStringLiteral("open"));
  19. reg->beginGroup(QStringLiteral("command"));
  20. reg->setValue(QStringLiteral("Default"), appPath + QLatin1String(" %1"));
  21.  
  22. return true;
  23.  
  24. #elif defined(Q_OS_UNIX)
  25. //TODO
  26. Logger::getInstance()->Info(tr("Cannot integrate with web browser - unsupported system"));
  27. return false;
  28. #endif
  29. return false;
  30. }
To copy to clipboard, switch view to plain text mode 

Receiving messages

Qt Code:
  1. void MainWindow::checkApplicationArguments()
  2. {
  3. for(int i = 0; i < QCoreApplication::arguments().count(); i++)
  4. {
  5. QString arg = QCoreApplication::arguments().at(i);
  6. if(arg.contains("myapp:["))
  7. {
  8. //do something
  9. }
  10. }
  11. }
To copy to clipboard, switch view to plain text mode 

... and then if we will register it, we can enter a message into web browser address bar and send it to our app, for example:
Qt Code:
  1. myapp:[hello]
To copy to clipboard, switch view to plain text mode 
then program will start and we can receive our message, but I'm wondering and I have completely no idea how to receive a message when app is currently running... normally web browser tries to open a new instance of application...
Have you got some idea how to handle application args when program is open ? I know that this is possible, I have seen it in different app about two years ago but the project is no longer being developed and I can't remember how it worked...

Thank you for time spent reading this topic
Cheers