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. Application output "flashes", but my GUI is not displayed on the screen.
Forum Updated to NodeBB v4.3 + New Features

Application output "flashes", but my GUI is not displayed on the screen.

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

    I have a problem with my project when a start with qDebug.
    In my code I have two .txt files that I need to read in my program. But when I
    put All.txt (my txt file) and dbconf.txt (my txt file) in my Working Directory my GUI doesn't show on screen.
    When I delete All.txt and dbconf.txt, my GUI show but my application has no purpose because I gotta read and write in these text files.
    How can I solve it?

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      It's impossible to help without looking at the code. There can be million number of reasons matching your brief description.

      1 Reply Last reply
      0
      • N Offline
        N Offline
        Neutrox
        wrote on last edited by
        #3

        this is just a part of my code, but now to view the file I try to open when starting the program.

        @{
        ui->setupUi(this);

        //Write all paths in the GUI when start the program.
        _directorydbconf = "dbconf.txt";
        
        
        if (!_directorydbconf.isEmpty()) {
                QFile file(_directorydbconf);
                if (!file.open(QIODevice::ReadOnly)) {
                    QMessageBox::critical(this, tr("Error"), tr("Could not open file"));
                    return;
                                                     }
        
                QTextStream in(&file);
                line1 = in.readLine();
                line12 = line1.mid(4);
                line2 = in.readLine();
                line21 = line2.mid(4);            //Reads from the fourth character
                ui->lineEdit_4->setText(line21);
                line3 = in.readLine();
                line31 = line3.mid(4);            //Reads from the fourth character
                ui->lineEdit_5->setText(line31);
                line4 = in.readLine();
                line41=line4.mid(4);              //Reads from the fourth character
                ui->lineEdit_6->setText(line41);
        
        
                                 }
        QFile file4(_directorydbconf);
        QTextStream in4(&file4);
        if(!file4.open(QFile::ReadOnly)){
                 qDebug() << "could not open file writing";
                            return;
        }else{
        for(int x=0; x<7; x++){
        
            _text11= in4.readLine();
        
        }
        
        }
        for(int x=0; x=7; x++){
        
        _text21= in4.readLine();
        }
        

        }
        @

        When I put the dbconf.txt file in the working directory, the GUI does not appear when I remove(dbconf.txt) the GUI file appears but with the mesagem "Could not open file".

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

          It looks like there might be an error in your code with where you declare QFile. YOu declare it inside some brackets but I think it is going out of scope where you create a datastream and try to read it Try moving QFile to the top of the program

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

            Yes, this is definitely an error. I'm wondering why compiler doesn't throw an error while trying to compile that code...

            1 Reply Last reply
            0
            • N Offline
              N Offline
              Neutrox
              wrote on last edited by
              #6

              Yes, there are errors.
              As I was learning and riding my application for a long time, I made mistakes I did not realize.
              I modified only the logic to read the file and opened it to read only once.

              Thanks for help! :)

              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