[Solved]Problem QT heritage : Can't compile a basic code
-
Hey all,
I just started to use QT 4.8 and I have a problem when I would make a heritage class.
I use Visual C++ 2010, I have configure my IDE and when I compile a basic appli, it works.
But when I tried to use heritage..My source :
main.cpp
@
#include "ONavMain.h"int main(int argc, char *argv[])
{
QApplication app(argc, argv);ONavMain appli;
appli.show();return app.exec();
}
@ONavMain.h
@
#ifndef ONAVMAIN_H
#define ONAVMAIN_H#include <QtGui/qapplication.h>
#include <QtGui/qtgui>class ONavMain : public QWidget
{
public:
ONavMain();
virtual ~ONavMain();protected:
private:
QPushButton *mBouton;};
#endif
@ONavMain.cpp
@
#include "ONavMain.h"ONavMain::ONavMain() : QWidget()
{
setFixedSize(1024, 768);mBouton = new QPushButton("", this);
mBouton->setFont(QFont("Arial"));
mBouton->setText("Bouton");
mBouton->setToolTip("Tooltip de Bouton");
mBouton->move(10, 5);
}ONavMain::~ONavMain()
{
delete mBouton;
mBouton = NULL;
}
@And the compile error is :
@La génération a démarré 20/02/2012 03:30:37.
1>Projet "C:\Users\Alastor\documents\visual studio 2010\Projects\Projects\Projects\Projects.vcxproj" sur le nœud 2 (build cible(s)).
1>Build:
qmake & nmakeMicrosoft (R) Program Maintenance Utility Version 10.00.30319.01 Copyright (C) Microsoft Corporation. Tous droits rÚservÚs. "C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\nmake.exe" -f Makefile.Debug Microsoft (R) Program Maintenance Utility Version 10.00.30319.01 Copyright (C) Microsoft Corporation. Tous droits rÚservÚs. cl -c -nologo -Zm200 -Zc:wchar_t- -Zi -MDd -GR -EHsc -W3 -w34100 -w34189 -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -I"c:\Qt\4.8.0\include\QtCore" -I"c:\Qt\4.8.0\include\QtGui" -I"c:\Qt\4.8.0\include" -I"." -I"c:\Qt\4.8.0\include\ActiveQt" -I"debug" -I"c:\Qt\4.8.0\mkspecs\win32-msvc2010" -Fodebug\ @C:\Users\Alastor\AppData\Local\Temp\nmC865.tmp main.cpp 1>.\main.cpp(11): error C2039: 'show' : n'est pas membre de 'QApplication' c:\qt\4.8.0\include\qtgui\../../src/gui/kernel/qapplication.h(97) : voir la déclaration de 'QApplication' 1>NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\cl.EXE"'á: code retour '0x2' Stop. 1>NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\nmake.exe"'á: code retour '0x2' Stop. 1>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: La commande "qmake & nmake" s'est arrêtée avec le code 2. 1>Génération du projet "C:\Users\Alastor\documents\visual studio 2010\Projects\Projects\Projects\Projects.vcxproj" terminée (build cible(s)) -- ÉCHEC.
ÉCHEC de la build.
Temps écoulé 00:00:06.13
@I hope that someone can help me.
Thanks for read, and please, excuse me for my poor english, I'm french. -
Well, your compiler output doesn't match the sources you've listed. Are you sure you are building the current project or is there any old code that might be opened as well and is built instead?
Two annotations:
- All QObject derived classes should have a default constructur having a parent parameter [code]ONavMain(QObject *parent = 0);[/code] resp. [code]ONavMain::ONavMain(QObject *parent) : QWidget(parent)[/code]
- You should use layouts instead of fixed positioning
-
Hum,
Thank you for your answer :
bq. Are you sure you are building the current projectI have regenerate my projetc and it's working.
I really look stupid ..
-
[quote author="Alastor" date="1329746353"]Thank you for your answer.
I have regenerate my projetc and it's working.[/quote]
You're welcome.[quote author="Alastor" date="1329746353"]
I really look stupid ..[/quote]
Nope. Such things just happen - to all of us.