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

[solved] Problem with console

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 734 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
    abich
    wrote on last edited by
    #1

    Hi i have a problem with my console
    I cannot display it, i had only the first message "please choose an xml....." in the application output.
    This is my code, And in my project.pro i had of course add QT += gui
    @
    #include<QApplication>
    ....
    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);

    MIRSpecLoad load;
    MIRSystem system;
    
    string fn;
    QString sfn;
    QFile f;
    
    do
    {
    std::cout<<"please choose an xml file name"<<std::endl;
    cin>>fn;
    sfn=sfn.fromUtf8(fn.c_str(),-1);
    QFile f(sfn);
    if (!(f.exists())) {cout<<"The file does not exist"<<endl; }
    }while (!(f.exists()));
    
    
      if (!load.openFile&#40;sfn&#41;)
      {
          std::cerr << "Failed to open the given file." << std::endl;
          return 0;
      }
      if(!load.parseSystem&#40;&system&#41;&#41;
      {
          std::cerr << "Unable to parse system." << std::endl;
          return 0;
      }
    

    return a.exec();

    }@

    Please can any one help me??

    1 Reply Last reply
    0
    • X Offline
      X Offline
      Xander84
      wrote on last edited by
      #2

      Hi, I don't think you can use std::cout or any other std console output in combination with the QApplication. As far as I know it will block the output until you exit the application and only after that you'll see the output from std::cout.

      I looked at some Qt example apps and I think they are using this to print to the console:
      @
      std::fputs("test", stdout);
      std::printf("test %d", 123);
      @
      i don't know if that makes any difference, but you could still use QDebug to print to the console, but that is only supposed for debug out usually :D

      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