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
Code:
bool Settings::registerProtocol() { #ifdef Q_OS_WIN reg->setValue(QStringLiteral("Default"), "download manager"); reg->beginGroup(QStringLiteral("DefaultIcon")); reg->endGroup(); reg->beginGroup(QStringLiteral("shell")); reg->beginGroup(QStringLiteral("open")); reg->beginGroup(QStringLiteral("command")); return true; #elif defined(Q_OS_UNIX) //TODO Logger::getInstance()->Info(tr("Cannot integrate with web browser - unsupported system")); return false; #endif return false; }
Receiving messages
Code:
void MainWindow::checkApplicationArguments() { { if(arg.contains("myapp:[")) { //do something } } }
... 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:
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...Code:
myapp:[hello]
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