Results 1 to 9 of 9

Thread: Program runs even if there is no code

  1. #1
    Join Date
    Oct 2014
    Posts
    21
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Program runs even if there is no code

    I have an Aplication(Qt Widgets Aplication). Inside I have 2 .cpp files (main,mainwindow). If i comment out all the includes in mainwindow the program still runs like nothing has happened. I think the program should instead throw an error.
    Am I right and the program should not run?

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Program runs even if there is no code

    Do a clean build and see what happens.

  3. #3
    Join Date
    Oct 2014
    Posts
    21
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Program runs even if there is no code

    1) cleaned the program
    2) Rebuild it
    3) than ran it

    This is the destructor :
    Qt Code:
    1. MainWindow::~MainWindow()
    2. {
    3. delete ui;
    4. db.close();
    5. qDebug() << "from destructor1";
    6. // delete model1;
    7. // delete model2;
    8. // qDebug() << "from destructor2";
    9. // qDebug() << ui->textBrowser_MySQL_log->toPlainText();
    10.  
    11. }
    To copy to clipboard, switch view to plain text mode 

    this is the output:
    Qt Code:
    1. from destructor1
    2. from destructor2
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Program runs even if there is no code

    So it seems that it is not rebuilt. How did you run it?
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  5. #5
    Join Date
    Oct 2014
    Posts
    21
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Program runs even if there is no code

    ctrl + r, green buton run

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Program runs even if there is no code

    Quote Originally Posted by Emit View Post
    ctrl + r, green buton run
    Try manually deleting the whole build directory of your project and see if the problem persists.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Oct 2014
    Posts
    21
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Program runs even if there is no code

    It looks like now runs as it should.

  8. #8
    Join Date
    Oct 2014
    Posts
    21
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Program runs even if there is no code

    Is there a bug in Qt creator or did I do something to make it not work?

  9. #9
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Program runs even if there is no code

    This is not a bug in Qt Creator. The actual compilation has nothing to do with Qt Creator; it merely hands it off to make after running qmake. If you mangle the file timestamps on your source/target files or tell make to build using the wrong files then you get unexpected results. This is quite obvious from the output of the build, which will show little or no actual compilation/linking activity because the target is "up to date". You should read and familiarise yourself with a normal build output.

Similar Threads

  1. This program runs, but does not work properly
    By rezas1000 in forum Qt Programming
    Replies: 3
    Last Post: 15th September 2014, 01:46
  2. Program runs from Creator, but not as a standalone?
    By N3wb in forum Qt Programming
    Replies: 12
    Last Post: 8th October 2012, 23:11
  3. Replies: 1
    Last Post: 7th March 2012, 21:34
  4. Program runs on Windows 7, crashes on Windows XP
    By JovianGhost in forum General Programming
    Replies: 8
    Last Post: 7th June 2010, 00:55
  5. Replies: 7
    Last Post: 4th June 2010, 14:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.