Holen Sie sich Parameter aus dem benutzerdefinierten URL -Schema für die C ++ - Mac App mit QT
Posted: 28 Feb 2025, 05:42
Ich habe eine Mac -App, die ich zu erstellen versuche. Ich möchte, dass es mit einem benutzerdefinierten URL -Schema ausgeführt wird und Params aufnimmt - zum Beispiel: Gameaway: //1.1.1? Ich kann die App einwandfrei starten, aber ich bekomme nie das Ereignis von QEVENT :: FileOpen . Es funktioniert, wenn ich es manuell über die Eingabeaufforderung ausführe (ich erhalte Argumente in Argc), aber nicht aus dem Browser. CFBundleURLTypes
CFBundleTypeRole
Viewer
CFBundleURLName
com.gameaway.app
CFBundleURLSchemes
gameaway
< /code>
Hier ist mein int main () in main.cpp: < /p>
int main(int argc, char *argv[])
{
qInfo() waitForDone(30000);
// Wait for pending log messages to be printed
s_LoggerThread.waitForDone();
return err;
}
< /code>
Und hier ist meine Anwendung.CPP (wo GameawayAnlication lebt): < /p>
#include "application.h"
GameAwayApplication::GameAwayApplication(int &argc, char **argv)
: QGuiApplication(argc, argv) {}
bool GameAwayApplication::event(QEvent *event) {
qInfo() url().toString();
qDebug()
CFBundleTypeRole
Viewer
CFBundleURLName
com.gameaway.app
CFBundleURLSchemes
gameaway
< /code>
Hier ist mein int main () in main.cpp: < /p>
int main(int argc, char *argv[])
{
qInfo() waitForDone(30000);
// Wait for pending log messages to be printed
s_LoggerThread.waitForDone();
return err;
}
< /code>
Und hier ist meine Anwendung.CPP (wo GameawayAnlication lebt): < /p>
#include "application.h"
GameAwayApplication::GameAwayApplication(int &argc, char **argv)
: QGuiApplication(argc, argv) {}
bool GameAwayApplication::event(QEvent *event) {
qInfo() url().toString();
qDebug()