Results 1 to 4 of 4

Thread: Cannot use a existing Designer UI File in my application

  1. #1
    Join Date
    Feb 2013
    Location
    San Diego
    Posts
    37
    Thanks
    14
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Cannot use a existing Designer UI File in my application

    I'm running Qt5.0.0 msvc2010 and I'm trying to add 3 files to a very basic project using the "add existing files" option of Qt Creator. The only intent of this project is to display a window created with Qt Designer.
    The 3 files are mainwindow.h, mainwindow.cpp and mainwindow.ui automatically generated by Qt Designer.
    When I try to compile, I get this: fatal error C1083: Cannot open include file: 'mainwindow.h': No such file or directory.

    The files are correctly located in my projet file and qmake runs fine.
    Qt Code:
    1. QT += widgets
    2. SOURCES += \
    3. main.cpp \
    4. ../test/mainwindow_test_form/mainwindow.cpp[ATTACH=CONFIG]8718[/ATTACH]
    5.  
    6. FORMS += \
    7. ../test/mainwindow_test_form/mainwindow.ui
    8.  
    9. HEADERS += \
    10. ../test/mainwindow_test_form/mainwindow.h
    To copy to clipboard, switch view to plain text mode 
    My main.cpp files look like this:
    Qt Code:
    1. #include <QApplication>
    2. #include <QtGui>
    3. #include "mainwindow.h"
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication app(argc, argv);
    7. MainWindow theMainWindow;
    8. theMainWindow.show();
    9. return app.exec();
    10. }
    To copy to clipboard, switch view to plain text mode 

    I tried to put the 3 files in different locations (in or out of the project) and I still get the same result.
    Any Suggestions?

    Thanks!


    I have attached a screenshot of my project in Qt Creator too. It might help.

  2. #2
    Join Date
    May 2008
    Location
    Tripoli Libya
    Posts
    70
    Thanks
    10
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Cannot use a existing Designer UI File in my application

    #include "mainwindow.h" ==> #include "../test/mainwindow_test_form/mainwindow.h"

  3. The following user says thank you to alrawab for this useful post:

    Guett_31 (14th February 2013)

  4. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Cannot use a existing Designer UI File in my application

    Or you can simply add
    qmake Code:
    1. INCLUDEPATH += ../test/mainwindow_test_form
    To copy to clipboard, switch view to plain text mode 
    to the pro file.

  5. The following user says thank you to Lykurg for this useful post:

    Guett_31 (14th February 2013)

  6. #4
    Join Date
    Feb 2013
    Location
    San Diego
    Posts
    37
    Thanks
    14
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Cannot use a existing Designer UI File in my application

    Thank to both of you! I tried both approachs and they work.
    I prefer Lykurg'a approach though. If the files change location later, I'll just have to update the path in one place.

Similar Threads

  1. Qt Creator open existing .pro file
    By check_in in forum Qt Tools
    Replies: 0
    Last Post: 21st October 2012, 21:11
  2. How to display an existing pdf file
    By newbie43 in forum Qt Programming
    Replies: 3
    Last Post: 4th February 2011, 17:11
  3. Replies: 3
    Last Post: 3rd August 2010, 14:12
  4. How to save an existing file
    By rk0747 in forum Qt Programming
    Replies: 1
    Last Post: 27th February 2010, 11:11
  5. Designer: How to promote to a existing Qt Widget?
    By nightghost in forum Qt Programming
    Replies: 2
    Last Post: 9th December 2009, 10:12

Tags for this Thread

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.