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. [RESOLVED] Console Application
Forum Updated to NodeBB v4.3 + New Features

[RESOLVED] Console Application

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

    Hello All,

    I develop a application that will every X seconds read a file.
    This already be done, but I have a big problem: I need keep the app running! I Use QTimer to Define the time of app read the file, but after read the first time the app stops to run.
    I just need keep this console app alive until send some kill signal or shutdown the machine.

    Any one can help me?
    Thanks all!

    1 Reply Last reply
    0
    • E Offline
      E Offline
      ElboyQt
      wrote on last edited by
      #2

      U should create "QApplication":qt-project.org/doc/qt-5/qapplication instance and call its "exec":http://qt-project.org/doc/qt-5/qapplication.html#exec method.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dcbasso
        wrote on last edited by
        #3

        I'm using QCoreApplication! As you can see:

        @
        #include <QCoreApplication>
        #include <control/control.h>

        int main(int argc, char argv[])
        {
        QCoreApplication a(argc, argv);
        Control
        control = new Control(&a);
        control->start();
        return a.exec();
        }@

        I will try QApplication...

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dcbasso
          wrote on last edited by
          #4

          I got this error:

          /usr/bin/ld: cannot find -lGL
          collect2: error: ld returned 1 exit status
          make: *** [KismetLog] Error 1
          17:25:54: The process "/usr/bin/make" exited with code 2.
          Error while building/deploying project KismetLog (kit: Desktop Qt 5.3 GCC 64bit)
          When executing step "Make"

          I add to .pro this: "QT += core xml xmlpatterns widgets" and change the main:

          @
          //#include <QCoreApplication>
          #include <QApplication>

          #include <control/control.h>

          int main(int argc, char argv[])
          {
          // QCoreApplication a(argc, argv);
          QApplication a(argc, argv);
          Control
          control = new Control(&a);
          control->start();
          return a.exec();
          }
          @

          1 Reply Last reply
          0
          • D Offline
            D Offline
            dcbasso
            wrote on last edited by
            #5

            QApplication is only for GUI apps.

            http://qt-project.org/doc/qt-5/qapplication.html#details

            1 Reply Last reply
            0
            • D Offline
              D Offline
              dcbasso
              wrote on last edited by
              #6

              Sorry guys... Just one error on my code!
              See you!

              Wrong:
              @
              if (this->timer = NULL) {
              @

              Correct:
              @
              if (this->timer == NULL) {
              @

              Very simple error. Thanks all.

              1 Reply Last reply
              0
              • IamSumitI Offline
                IamSumitI Offline
                IamSumit
                wrote on last edited by
                #7

                Hi.
                it seems you have solved problem by yourself that's good.
                So, please update your thread title as [SOLVED] .
                Thanks.

                Be Cute

                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  Resurrection
                  wrote on last edited by
                  #8

                  Related, but you could use QFileSystemWatcher instead of timer for reading the file... Unless there is a reason why you want to read it every fixed amount of time. :-)

                  Secrets are power.

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    dcbasso
                    wrote on last edited by
                    #9

                    Yes I have to read every 60 seconds the file, I will process in the raspberry and send the processed information to a server.
                    But I will take a look at QFileSystemWatcher, appears to be something very useful!

                    Thanks for your tip!

                    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