[C++] Comment installer et se servir de Qt so

Bonsoir,

après avoir apris le c++ (depuis quelque temps) je voudrais m'intéraisser à Qt.
Mais je ne comprend pas langlais et donc comment on installe Qt et comment on s'en sert.

Mon but final est de faire un logiciel comme bloc note et puis de l'améliorer par la suite.
Mais pour le moment faudrait déjà que je sache me servir de Qt et en tout premier lieu l'installer.

Donc si quelqu'un a le courage je l'en remercie!

9 réponses

  • Votes
  • Date
  • Date décroissante
  1. Modérateur
    Essaye a.setMainWidget(hello); à tout hasard, ça me paraîtrait plus logique que &hello. Car en fait si ca se trouve le QButton hérite bien de QWidget.
    1. Je sais qu'il y a eu beaucoup de modification sur Qt 4 et c'est pour ça que j'ai beaucoup de mal lol..
      Merci de ton aide. :)
      1. Modérateur
        http://doc.trolltech.com/4.3/qapplication-qt3.html#setMainWidget

        La fonction setMainWidget attend un QWidget et apparemment un QPushButton n'en hérite pas... L'exemple ne marche apparemment pour qt4.3 ?
        1. Modérateur
          Quel est le message d'erruer quand tu compiles ?

          Le tutoriel donné ici :
          http://doc.trolltech.com/3.3/tutorial1-01.html
          donne le code suivant :
          /****************************************************************
          **
          ** Qt tutorial 1
          **
          ****************************************************************/
          
          #include <qapplication.h>
          #include <qpushbutton.h>
          
          
          int main( int argc, char **argv )
          {
              QApplication a( argc, argv );
          
              QPushButton hello( "Hello world!", 0 );
              hello.resize( 100, 30 );
          
              a.setMainWidget( &hello );
              hello.show();
              return a.exec();
          }

          En particulier il est primordial de respecter les majuscules/minuscules dans les noms de headers et de classe et de mettre le .h, chose que tu n'as pas fait. A noter que sauf exceptions, seuls les headers de la STL ne prennent pas de ".h" au bout.

          Bonne chance
          1. Voici l'erreur obtenu (avec ton code):

            Compilateur: Default compiler
            Building Makefile: "D:\Documents and Settings\Propriétaire\Mes documents\programme test C-C++\test qt marche sous dev c++\Makefile.win"
            Exécution de  make...
            make.exe -f "D:\Documents and Settings\Propriétaire\Mes documents\programme test C-C++\test qt marche sous dev c++\Makefile.win" all
            g++.exe -c main.cpp -o main.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"  -I"C:/Dev-Cpp/include/c++/3.4.2/backward"  -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32"  -I"C:/Dev-Cpp/include/c++/3.4.2"  -I"C:/Dev-Cpp/include"  -O2 -O2 -frtti -fexceptions -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DQT_CORE_LIB -DQT_GUI_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"C:\Qt\4.3.0\include\QtGui" -I"C:\Qt\4.3.0\include\QtCore" -I"C:\Qt\4.3.0\include" -I"." -I"C:\Qt\4.3.0\include\ActiveQt" -I"tmp\moc\release_shared" -I"." -I"C:\Qt\4.3.0\mkspecs\win32-g++" 
            
            main.cpp: In function `int qMain(int, char**)':
            main.cpp:8: error: 'class QApplication' has no member named 'setMainWidget'
            
            make.exe: *** [main.o] Error 1
            
            Exécution terminée
            


            <b>main.cpp</b>

             #include <qapplication.h>
             #include <qpushbutton.h>    
             int main( int argc, char **argv )
             {    
                  QApplication a( argc, argv );      
                  QPushButton hello( "Hello world!", 0 );    
                  hello.resize( 100, 30 );      
                  a.setMainWidget( &hello );    /*************** ERREUR A CETTE LIGNE   ********************/
                  hello.show();    
                  return a.exec();
             }
             
            


            Merci de ton aide :)
        2. Voici le code qui ne compile pas:

          #include <QApplication>
          #include <QPushButton>
          
          int main(int argc, char *argv[])
          {
              QApplication app(argc, argv);
          
              QPushButton hello("Hello world!");
              hello.resize(100, 30);
          
              hello.show();
              return app.exec();
          }
          
          1. Je ne trouve toujours pas j'ai passé l'aprèmidis à faire plein de test différent mais ça ne change rien.
            Personne ne trouve?
            1. Après avoir suivi le tutorial: https://nicolasj.developpez.com/articles/qt4/

              Dev c++ ne veux pas compiller. Voici ce qu'il dit:

              Compilateur: Default compiler
              Building Makefile: "D:\Documents and Settings\Propriétaire\Mes documents\programme test C-C++\test qt marche sous dev c++\Makefile.win"
              Exécution de  make...
              make.exe -f "D:\Documents and Settings\Propriétaire\Mes documents\programme test C-C++\test qt marche sous dev c++\Makefile.win" all
              g++.exe -c main.cpp -o main.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"  -I"C:/Dev-Cpp/include/c++/3.4.2/backward"  -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32"  -I"C:/Dev-Cpp/include/c++/3.4.2"  -I"C:/Dev-Cpp/include"  -O2 -O2 -frtti -fexceptions -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DQT_CORE_LIB -DQT_GUI_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"C:\Qt\4.3.0\include\QtGui" -I"C:\Qt\4.3.0\include\QtCore" -I"C:\Qt\4.3.0\include" -I"." -I"C:\Qt\4.3.0\include\ActiveQt" -I"tmp\moc\release_shared" -I"." -I"C:\Qt\4.3.0\mkspecs\win32-g++" 
              
              windres.exe -i Projet1_private.rc --input-format=rc -o Projet1_private.res -O coff 
              
              windres.exe: no resources
              
              make.exe: *** [Projet1_private.res] Error 1
              
              Exécution terminée
              


              Je ne comprend pas..

              Qt.template

              [Template]
              ver=1
              Name=Qt
              Icon=C:\Qt\4.3.0\demos\qtdemo\qtdemo.ico
              Description=Create a GUI using the Qt library.
              Catagory=GUI
              
              [Unit0]
              CppName=main.cpp
              Cpp=Qt_cpp.txt
              
              [Project]
              UnitCount=1
              Type=1
              IsCpp=1
              CppCompiler=-O2 -O2 -frtti -fexceptions -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DQT_CORE_LIB -DQT_GUI_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"C:\Qt\4.3.0\include\QtGui" -I"C:\Qt\4.3.0\include\QtCore" -I"C:\Qt\4.3.0\include" -I"." -I"C:\Qt\4.3.0\include\ActiveQt" -I"tmp\moc\release_shared" -I"." -I"C:\Qt\4.3.0\mkspecs\win32-g++"
              Linker=-mthreads -Wl,-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-s -Wl,-s -Wl,-subsystem,windows -L"C:\Qt\4.3.0\lib" -L"C:\Qt\4.3.0\lib" -lmingw32 -lqtmain -lQtCore4 -lQtGui4
              ProjectIcon=Qt.ico


              Merci de votre aide si vous arrivez à trouver le bug.. lol