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()
Forum Update on Monday, May 27th 2025

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 11 Jan 2017, 02:34 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

    F 1 Reply Last reply 11 Jan 2017, 03:04
    0
    • T tmas
      11 Jan 2017, 02:34

      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

      F Offline
      F Offline
      Flotisable
      wrote on 11 Jan 2017, 03:04 last edited by
      #2

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

      J M 2 Replies Last reply 11 Jan 2017, 05:35
      1
      • F Flotisable
        11 Jan 2017, 03:04

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

        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 11 Jan 2017, 05:35 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
        • V Offline
          V Offline
          VRonin
          wrote on 11 Jan 2017, 08:10 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
          • F Flotisable
            11 Jan 2017, 03:04

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

            M Offline
            M Offline
            m.sue
            wrote on 11 Jan 2017, 08:32 last edited by m.sue 1 Nov 2017, 08:33
            #5
            This post is deleted!
            1 Reply Last reply
            0

            4/5

            11 Jan 2017, 08:10

            • Login

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