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. I cant use console application

I cant use console application

Scheduled Pinned Locked Moved General and Desktop
10 Posts 4 Posters 3.0k 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.
  • H Offline
    H Offline
    hor_313
    wrote on last edited by
    #1

    hi

    when i build a console program i cant see results in terminal page . just opened a empty terminal page and doesnt show anythings!

    i dont know why and i'll be happy if anyone helps me

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Serenity
      wrote on last edited by
      #2

      Can you please post your written code to see, what's wrong?
      I am not sure, what you meen with "doesn't show anything". Which system are you using?

      1 Reply Last reply
      0
      • M Offline
        M Offline
        MuldeR
        wrote on last edited by
        #3

        This is far too vague to say anything helpful.

        Please say at least which platform you are on and show a meaningful piece of your code.

        My OpenSource software at: http://muldersoft.com/

        Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

        Go visit the coop: http://youtu.be/Jay...

        1 Reply Last reply
        0
        • H Offline
          H Offline
          hor_313
          wrote on last edited by
          #4

          thanks dears .

          i have not any code. just i tested it and didnt get any result .

          my simple code is :
          @
          #include <QCoreApplication>
          #include <iostream>

          using namespace std;

          int main(int argc, char *argv[])
          {
          QCoreApplication a(argc, argv);
          cout<<"aaaa";
          //printf("ssss");
          return a.exec();
          }
          @

          and i am in ubuntu 12.04 OS with qtcreator 2.5 and qt4.8.1 sdk.

          when i execute that code a empty terminal box opens and i can write into but it doesnt any work!

          1 Reply Last reply
          0
          • H Offline
            H Offline
            hor_313
            wrote on last edited by
            #5

            !http://upcity.ir/images/23171340833418290646.png(problem's_picture)!

            1 Reply Last reply
            0
            • H Offline
              H Offline
              hor_313
              wrote on last edited by
              #6

              this code is in .pro-file too :

              @
              QT += core

              QT -= gui

              TARGET = test1
              CONFIG += console
              CONFIG -= app_bundle

              TEMPLATE = app

              SOURCES += main.cpp
              @

              1 Reply Last reply
              0
              • M Offline
                M Offline
                MuldeR
                wrote on last edited by
                #7

                I'm not quite sure about how this is on Linux, but on the Windows platform applications can be compiled as "Windows" or as "Console" applications. That's a Linker option. If you compile as "Windows", which is the default for GUI apps, then the app doesn't have a console. And even if you run it from a console - or allocate a console at runtime via AllocConsole() function - output to the console via "stdout" or "cout" doesn't work. Bummer! That's because the C Runtime never binds the stdout/stderr or cout/cerr to the console - because it doesn't expect a console to be there. There are some workarounds for that. Maybe on Linux there is a similar issue. I'm not quite sure. Maybe somebody more familiar with Linux can give an answer about that...

                My OpenSource software at: http://muldersoft.com/

                Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

                Go visit the coop: http://youtu.be/Jay...

                1 Reply Last reply
                0
                • batistaB Offline
                  batistaB Offline
                  batista
                  wrote on last edited by
                  #8

                  @
                  //This is working!!!, put endl for end cout

                  #include <QCoreApplication>
                  #include <iostream>
                   
                  using namespace std;
                   
                  int main(int argc, char *argv[])
                  {
                      QCoreApplication a(argc, argv);
                      cout<<"aaaa" << endl;
                      //printf("ssss");
                      return a.exec(&#41;;
                  }
                  

                  @

                  1 Reply Last reply
                  0
                  • H Offline
                    H Offline
                    hor_313
                    wrote on last edited by
                    #9

                    [quote author="batista" date="1361676392"]@
                    //This is working!!!, put endl for end cout

                    #include <QCoreApplication>
                    #include <iostream>
                     
                    using namespace std;
                     
                    int main(int argc, char *argv[])
                    {
                        QCoreApplication a(argc, argv);
                        cout<<"aaaa" << endl;
                        //printf("ssss");
                        return a.exec(&#41;;
                    }
                    

                    @[/quote]

                    i put it but didnt work !

                    1 Reply Last reply
                    0
                    • batistaB Offline
                      batistaB Offline
                      batista
                      wrote on last edited by
                      #10

                      @
                      //My test in debian and ubuntu 12.10 work fine.

                      batista@dellxps:~/NetBeansProjects/QtTes$ cat test.cpp
                      #include <QCoreApplication>
                      #include <iostream>

                      using namespace std;
                       
                      int main(int argc, char *argv[])
                      {
                          QCoreApplication a(argc, argv);
                          cout<<"aaaa" << endl;
                          //printf("ssss");
                          return a.exec&#40;&#41;;
                      }
                      

                      batista@dellxps:~/NetBeansProjects/QtTes$ ./QtTes
                      aaaa

                      @

                      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