Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    QGuiApplication - reference in argc argument

    General and Desktop
    3
    4
    1628
    Loading More Posts
    • 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.
    • M
      Milovidov last edited by

      QGuiApplication have this signature in constructor:
      @QGuiApplication(int & argc, char ** argv)@

      But, why it need? I had derived class from QGuiApplication with signature in constructor without reference:
      @MyApplication(int argc, char ** argv) : QGuiApplication(argc, argv)@

      And of cource, starting at a certain point my app started to fall. I spent many time for fix this problem and now i have a question. Why it need? Integer type have equal or more than twice size than pointer, and using only once. But this reference can create similar errors, as i did.

      1 Reply Last reply Reply Quote 0
      • sierdzio
        sierdzio Moderators last edited by

        A good question. I've never contemplated that. The only explanation I can think of and that carries enough weight to be mentioned, is that QCoreApplication does reserve right to modify arguments list (see "documentation":http://qt-project.org/doc/qt-4.8/qapplication.html#QApplication - QApplication is what QGuiApplication was before Qt5).
        [quote]Note: argc and argv might be changed as Qt removes command line arguments that it recognizes.[/quote]

        (Z(:^

        1 Reply Last reply Reply Quote 0
        • M
          Milovidov last edited by

          Ok, i understand. I saw this documentation eirler, but didn't see dependence with argc argument.

          1 Reply Last reply Reply Quote 0
          • Chris Kawa
            Chris Kawa Moderators last edited by

            Theoretically you could check how many arguments Qt has processed by comparing argc value before and after QApplication creation, but honestly this is a little silly use case and I can't find better one.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post