PDA

View Full Version : QT program start without proper main window



s_eye
1st July 2014, 16:52
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.

10492
10493

anda_skoa
2nd July 2014, 08:01
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,
_

s_eye
2nd July 2014, 08:20
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)

anda_skoa
2nd July 2014, 09:37
Those are the sources of three applications.
Which one is the one you are building/running?

Cheers,
_

s_eye
2nd July 2014, 10:05
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.


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

Cheers,
_

anda_skoa
2nd July 2014, 12:10
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,
_

s_eye
2nd July 2014, 13:06
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.