Results 1 to 7 of 7

Thread: QT program start without proper main window

  1. #1
    Join Date
    Sep 2013
    Posts
    4
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QT program start without proper main window

    I'm porting one example in Mark Summerfield's book: Advanced Qt Programming to QT5. I'm using QT 5.3.1&vs2013. I made some change in .pro and the source code so that the project can be build.

    but when the exe runs, it shows another window(textitem dialog of the project), not the main window(an graphical editor) of the program.

    the main.cpp is as following:

    int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);
    MainWindow window;
    window.show();


    app.setApplicationName(app.translate("main", "Page Designer"));
    app.setOrganizationName("Qtrac Ltd.");
    app.setOrganizationDomain("qtrac.eu");
    app.setWindowIcon(QIcon(":/icon.png"));
    #ifdef Q_WS_MAC
    app.setCursorFlashTime(0);
    #endif

    qsrand(static_cast<uint>(time(0)));

    return app.exec();
    }

    due the upload limit, I can't attach the source(The source should be build with QT greater than 5.0). but I can send it by mail .

    I think this problem doesn't belong to QT5 only.

    does anyone knows why? thank you in andvance.

    improper window.png
    mainwindow-should-be.jpg

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,419
    Thanks
    37
    Thanked 1,546 Times in 1,496 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QT program start without proper main window

    You should be able to attach a ZIP file with the program's sources without hitting any limit.
    Make sure the folder does not contain any build artifacts before you zip it.

    Cheers,
    _

  3. #3
    Join Date
    Sep 2013
    Posts
    4
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QT program start without proper main window

    thank you!

    I've uploaded the source and EXE of the project(QT DLLs are needed to be in the path variable to run the EXE demo)
    Attached Files Attached Files

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,419
    Thanks
    37
    Thanked 1,546 Times in 1,496 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QT program start without proper main window

    Those are the sources of three applications.
    Which one is the one you are building/running?

    Cheers,
    _

  5. #5
    Join Date
    Sep 2013
    Posts
    4
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QT program start without proper main window

    the .pro file is in the directory: pagedesigner1.

    the directory is as the demo was provided in the book: advanced qt programming, by Mark Summerfield.
    thank you.

    Quote Originally Posted by anda_skoa View Post
    Those are the sources of three applications.
    Which one is the one you are building/running?

    Cheers,
    _

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,419
    Thanks
    37
    Thanked 1,546 Times in 1,496 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QT program start without proper main window

    Well, the screenshot you have posted is from the textedit example.

    Check that you have only the pagedesigner1 project loaded or that it is the active project.

    Cheers,
    _

  7. #7
    Join Date
    Sep 2013
    Posts
    4
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QT program start without proper main window

    Quote Originally Posted by anda_skoa View Post
    Well, the screenshot you have posted is from the textedit example.

    Check that you have only the pagedesigner1 project loaded or that it is the active project.

    Cheers,
    _
    thank you for your help! the problem is solved(after I renamed the main.cpp in directory textedit). I've always open the pagedesigner1.pro(not textedit.pro).
    following is part of the .pro file:
    HEADERS += ../textedit/textedit.hpp
    SOURCES += ../textedit/textedit.cpp
    RESOURCES += ../textedit/textedit.qrc
    INCLUDEPATH += ../textedit

    HEADERS += mainwindow.hpp
    SOURCES += mainwindow.cpp
    SOURCES += main.cpp
    RESOURCES += pagedesigner.qrc

    so, what should be used is the main.cpp in dir pagedesigner1, but there is also a main.cpp in dir textedit, note that the latter isn't mentioned in .pro file.

    however, during the build process, the latter main.cpp was taken as the main file, and improper window was showen.

    I wonder if it is a bug of Qt.

Similar Threads

  1. Replies: 2
    Last Post: 11th August 2012, 09:27
  2. Console Window flashes when I start my Qt program
    By Uziel in forum Qt Programming
    Replies: 1
    Last Post: 12th December 2011, 22:07
  3. Program wont start - Wont even enter main()
    By ComServant in forum General Programming
    Replies: 5
    Last Post: 8th January 2011, 04:44
  4. Replies: 11
    Last Post: 11th August 2008, 10:14
  5. Replies: 5
    Last Post: 29th October 2007, 23:49

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.