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. [Solved]QString input using argv
Forum Updated to NodeBB v4.3 + New Features

[Solved]QString input using argv

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 9.3k Views 1 Watching
  • 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.
  • A Offline
    A Offline
    alex.dadaev
    wrote on 15 Feb 2011, 12:21 last edited by
    #1

    maybe i should use getopt() ?

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      Zlatomir
      wrote on 15 Feb 2011, 12:26 last edited by
      #2

      This doesn't do what you expect:
      @for(int i=0;i<=argc;++i) {
      str[i] = argv[i];@
      str[i] is an QChar (and is invalid since the code QString str; constructs and empty string)

      You can use "QStringList":http://doc.qt.nokia.com/latest/qstringlist.html and copy each argv into a QString in the list.

      LE: also QApplication has "arguments()":http://doc.qt.nokia.com/latest/qcoreapplication.html#arguments member function returns a QStringList (you pass the arguments when you construct the QApplication object: QApplication app(argc, argv);.

      And it's a nice and respectful to mark the edits for your posts, else we might look like crazy people answering programming questions ;)

      https://forum.qt.io/category/41/romanian

      1 Reply Last reply
      0
      • G Offline
        G Offline
        goetz
        wrote on 15 Feb 2011, 12:37 last edited by
        #3

        What about "QCoreApplication::arguments() ":http://doc.qt.nokia.com/4.7/qcoreapplication.html#arguments? It already parses the arguments into a QStringList.

        http://www.catb.org/~esr/faqs/smart-questions.html

        1 Reply Last reply
        0
        • A Offline
          A Offline
          alex.dadaev
          wrote on 15 Feb 2011, 14:18 last edited by
          #4

          Than you :)

          1 Reply Last reply
          0

          1/4

          15 Feb 2011, 12:21

          • Login

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