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] GUI with arguments
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] GUI with arguments

Scheduled Pinned Locked Moved General and Desktop
6 Posts 4 Posters 8.6k 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.
  • B Offline
    B Offline
    beowulf
    wrote on last edited by
    #1

    There a way Qt Gui receive an application parameters? And how to put predefined parameters in Qt Creator to build the application?

    @qDebug() << application.arguments();@

    -- 0x00

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Code_ReaQtor
      wrote on last edited by
      #2

      they are received in the main.cpp file of all Qt projects. What you need is to retrieve the arguments in the "main" and send it to your "mainwindow" class by the constructor or by a public function.

      Please visit my open-source projects at https://github.com/Code-ReaQtor.

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lgeyer
        wrote on last edited by
        #3

        [quote author="l3e0wulf" date="1359012305"]There a way Qt Gui receive an application parameters?[/quote]"Accessing Command Line Arguments":http://qt-project.org/doc/qt-5.0/qtcore/qcoreapplication.html#accessing-command-line-arguments

        [quote author="l3e0wulf" date="1359012305"]And how to put predefined parameters in Qt Creator to build the application?[/quote]"Specifying Run Settings for Desktop Device Types":http://qt-project.org/doc/qtcreator-2.6/creator-run-settings.html#specifying-run-settings-for-desktop-device-types

        1 Reply Last reply
        0
        • A Offline
          A Offline
          AcerExtensa
          wrote on last edited by
          #4

          There is no difference for command line arguments between GUI and console application in Qt. They are always available through qApp->arguments().
          In Qt Creator you can define your custom arguments in Project settings.

          -Looks like i was to slow :)-

          God is Real unless explicitly declared as Integer.

          1 Reply Last reply
          0
          • B Offline
            B Offline
            beowulf
            wrote on last edited by
            #5

            Thanks solved!

            mainwindow.h:
            @explicit MainWindow(QStringList, QWidget *parent = 0);@

            mainwindow.cpp:
            @MainWindow::MainWindow(QStringList arguments, QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
            {

            ui->setupUi(this);
            
            qDebug() << arguments;
            

            }@

            main.cpp:
            @MainWindow window(a.arguments());@

            -- 0x00

            1 Reply Last reply
            0
            • A Offline
              A Offline
              AcerExtensa
              wrote on last edited by
              #6

              -Please add "[SOLVED]" prefix to the topic subject. Thanks!-

              God is Real unless explicitly declared as Integer.

              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