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. argc change value when calling Qcoreapplication::arguments()
QtWS25 Last Chance

argc change value when calling Qcoreapplication::arguments()

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 5 Posters 1.8k 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.
  • T Offline
    T Offline
    tmas
    wrote on last edited by
    #1

    Hi,

    I have a class App deriving from QApplication and
    with contructor App::App( int& argc, char *argv[] )
    In one of the member of the class App, I am doing
    QStringList Args = QCoreApplication::arguments();
    When I run my application I know that app is created with
    argc at 0 anf argv at "" .
    I have a crash when I call QCoreApplication::arguments().
    I traced the problem until const int ac = self->d_func()->argc;
    where ac will contain a value greater than 0 ( never the same).
    I don't change argc at the application level

    I see that argc and self->d_func()->argc have the same adress but I cannot see where argc value changed.
    Any idea?

    Thierry

    FlotisableF 1 Reply Last reply
    0
    • T tmas

      Hi,

      I have a class App deriving from QApplication and
      with contructor App::App( int& argc, char *argv[] )
      In one of the member of the class App, I am doing
      QStringList Args = QCoreApplication::arguments();
      When I run my application I know that app is created with
      argc at 0 anf argv at "" .
      I have a crash when I call QCoreApplication::arguments().
      I traced the problem until const int ac = self->d_func()->argc;
      where ac will contain a value greater than 0 ( never the same).
      I don't change argc at the application level

      I see that argc and self->d_func()->argc have the same adress but I cannot see where argc value changed.
      Any idea?

      Thierry

      FlotisableF Offline
      FlotisableF Offline
      Flotisable
      wrote on last edited by
      #2

      @tmas
      do you set argc by the argc in main?
      I remember that argc is at least 1.

      jsulmJ m.sueM 2 Replies Last reply
      1
      • FlotisableF Flotisable

        @tmas
        do you set argc by the argc in main?
        I remember that argc is at least 1.

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @Flotisable Yes, at the first position in argv there should be the name of the executable.
        @tmas how do you use your App class?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by
          #4

          From http://doc.qt.io/qt-5/qcoreapplication.html#QCoreApplication

          Warning: [...] argc must be greater than zero and argv must contain at least one valid character string.

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          1 Reply Last reply
          1
          • FlotisableF Flotisable

            @tmas
            do you set argc by the argc in main?
            I remember that argc is at least 1.

            m.sueM Offline
            m.sueM Offline
            m.sue
            wrote on last edited by m.sue
            #5
            This post is deleted!
            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