Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to get .exe parameters into QML app?
QtWS25 Last Chance

How to get .exe parameters into QML app?

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 3 Posters 2.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    strekazoid
    wrote on last edited by
    #1

    I have these in main.cpp:

    int main(int argc, char *argv[])

    How do I get the provided parameters to my QML layer? Like, if my .exe is launched with a certain key and value, how is it possible to communicate this to the QML layer?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      I would do the argument parsing in C++, and just expose the relevant options to QML using a QObject with some properties.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        strekazoid
        wrote on last edited by
        #3

        I think I found how to parse the arguments with QCoreApplication::arguments(). But how do I comminucate the parsed stuff to QML? QmlApplicationViewer->rootContext()->setContextProperty ?

        1 Reply Last reply
        0
        • L Offline
          L Offline
          lgeyer
          wrote on last edited by
          #4

          That's the way to go.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            strekazoid
            wrote on last edited by
            #5

            Ok, thanks, will try :D

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved