Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QGuiApplication - reference in argc argument

QGuiApplication - reference in argc argument

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 1.9k 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.
  • M Offline
    M Offline
    Milovidov
    wrote on last edited by
    #1

    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
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      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
      0
      • M Offline
        M Offline
        Milovidov
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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
          0

          • Login

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