Results 1 to 12 of 12

Thread: Qt resources system don't work for a simple example

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2012
    Posts
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Qt resources system don't work for a simple example

    Hey guys,

    Since I have installed Qt 4.8.2, I can't use the Qt system resources because the resources are not compiled during compilation. Maybe is there another feature to be activated now ? I work with Qt 4.8.2 on Windows Vista and I don't try yet if I have the same problem in my Linux system. For information, I have download the Qt libraries 4.8.2 for Windows (minGW 4.4, 318 MB) and Qt Creator 2.5.2 for Windows (30 MB) on Nokia downloads page.

    Here is my simple example :

    Test.pro
    Qt Code:
    1. #-------------------------------------------------
    2. #
    3. # Project created by QtCreator 2012-08-21T18:03:11
    4. #
    5. #-------------------------------------------------
    6.  
    7. QT += core gui
    8.  
    9. #The follow line appears with Qt 4.8.2
    10. greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    11.  
    12. TEMPLATE = app
    13. CONFIG += release
    14. MOC_DIR = ./moc/
    15. RCC_DIR = ./qrc/
    16. OBJECTS_DIR = ./obj/
    17. DESTDIR = ./
    18. TARGET = Test
    19.  
    20. SOURCES += main.cpp
    21.  
    22. HEADERS +=
    23.  
    24. RESOURCES += ressources.qrc
    To copy to clipboard, switch view to plain text mode 

    main.cpp
    Qt Code:
    1. #include <QApplication>
    2. #include <QTabWidget>
    3. #include <QTextEdit>
    4. #include <QCalendarWidget>
    5.  
    6. int main(int argc, char *argv[])
    7. {
    8. QApplication a(argc, argv);
    9.  
    10. QTabWidget tabWidget;
    11.  
    12. tabWidget.setMovable(true);
    13.  
    14. QTextEdit textEdit;
    15. tabWidget.addTab(&textEdit, QIcon(":/Desktop.png"), "Text edit");
    16. QCalendarWidget calendarWidget;
    17. tabWidget.addTab(&calendarWidget, QIcon(":/Star.png"), "Calendar widget");
    18.  
    19. tabWidget.show();
    20.  
    21. return a.exec();
    22. }
    To copy to clipboard, switch view to plain text mode 

    resources.qrc
    Qt Code:
    1. <RCC>
    2. <qresource>
    3. <file>Desktop.png</file>
    4. <file>Star.png</file>
    5. </qresource>
    6. </RCC>
    To copy to clipboard, switch view to plain text mode 

    The .pro, .cpp, .qrc and .png files are in the same location of course.
    Finally, images doesn't appear during execution because they can't be loaded.

    During compilation when I used Qt 4.8.0, these commands appeared :

    rcc -name ressources ressources.qrc -o qrc\qrc_ressources.cpp
    g++ -c -O2 -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT
    -DNDEBUG -DQT_DLL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX
    -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT
    -DQT_NEEDS_QMAIN -I'd:/Applis/Qt/4.8.2/include/QtCore' -I'd:/Applis/Qt/4.8.2/include/QtGui'
    -I'd:/Applis/Qt/4.8.2/include' -I'.' -I'd:/Applis/Qt/4.8.2/include/ActiveQt' -I'./moc'
    -I'd:/Applis/Qt/4.8.2/mkspecs/win32-g++' -o ./qrc_ressources.o ./qrc/qrc_ressources.cpp

    And of course, the generated .o file was added during the executable creation.

    Have you any idea ?

    Regards,

    P'tit Ju
    Last edited by P'tit Ju; 24th August 2012 at 12:11.

  2. #2
    Join Date
    Oct 2009
    Posts
    483
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanked 97 Times in 94 Posts

    Default Re: Qt resources system don't work for a simple example

    How do you know that the resources cannot be loaded? Have you tried reading them directly with QFile? For all we know the problem might be in the PNG rendering, or the files may be corrupted.

  3. #3
    Join Date
    Aug 2012
    Posts
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt resources system don't work for a simple example

    I know that because whe you try to load them with QPixmap, they are null and these pictures are from Qt : Desktop.pngStar.png .
    If you want, here is the output of the compilation (some words are in french because I am) and you see that the resource file doesn't appear anywhere :

    Qt Code:
    1. 12:05:20: Le processus "D:\Applis\Qt\mingw\bin\mingw32-make.exe" s'est terminé normalement.
    2. 12:05:20: Configuration inchangée, étape QMake sautée.
    3. 12:05:20: Débute : "D:\Applis\Qt\mingw\bin\mingw32-make.exe"
    4. g++ -c -O2 -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I'd:/Applis/Qt/4.8.2/include/QtCore' -I'd:/Applis/Qt/4.8.2/include/QtGui' -I'd:/Applis/Qt/4.8.2/include' -I'd:/Applis/Qt/4.8.2/include/ActiveQt' -I'moc' -I'd:/Applis/Qt/4.8.2/mkspecs/win32-g++' -o obj/main.o main.cpp
    5. g++ -Wl,-s -mthreads -Wl,-subsystem,windows -o Test.exe obj/main.o -L'd:/Applis/Qt/4.8.2/lib' -lmingw32 -lqtmain -lQtGui4 -lQtCore4
    6. 12:05:23: Le processus "D:\Applis\Qt\mingw\bin\mingw32-make.exe" s'est terminé normalement.
    To copy to clipboard, switch view to plain text mode 

    The only solution I found for moment is to do this manuallly in a Qt console : rcc -name ressources ressources.qrc -o qrc\qrc_ressources.cpp .
    And in the .pro file, add this line : SOURCES += qrc_ressources.cpp .
    It works well but it's not practical...

  4. #4
    Join Date
    Aug 2012
    Posts
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt resources system don't work for a simple example

    I try it on my Xubuntu Linux with Qt 4.8.2.0 and it works. Here is the compilation output :

    Qt Code:
    1. 12:11:47: Configuration inchangée, étape QMake sautée.
    2. 12:11:47: Débute : "/usr/bin/make" -w
    3. make: Entering directory `/home/julien/Test'
    4. g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.8.2/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/Qt-4.8.2/include/QtCore -I/usr/local/Trolltech/Qt-4.8.2/include/QtGui -I/usr/local/Trolltech/Qt-4.8.2/include -Imoc -o obj/main.o main.cpp
    5. /usr/local/Trolltech/Qt-4.8.2/bin/rcc -name ressources ressources.qrc -o qrc/qrc_ressources.cpp
    6. g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.8.2/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/Qt-4.8.2/include/QtCore -I/usr/local/Trolltech/Qt-4.8.2/include/QtGui -I/usr/local/Trolltech/Qt-4.8.2/include -Imoc -o obj/qrc_ressources.o qrc/qrc_ressources.cpp
    7. g++ -Wl,-O1 -Wl,-rpath,/usr/local/Trolltech/Qt-4.8.2/lib -o Test obj/main.o obj/qrc_ressources.o -L/usr/local/Trolltech/Qt-4.8.2/lib -lQtGui -L/usr/local/Trolltech/Qt-4.8.2/lib -L/usr/X11R6/lib -lQtCore -lpthread
    8. make: Leaving directory `/home/julien/Test'
    9. 12:11:50: Le processus "/usr/bin/make" s'est terminé normalement.
    To copy to clipboard, switch view to plain text mode 

    You can see there is some text that doesn't appear in the Windows compilation output. Is it a problem with qmake ?
    Is there anybody who has a solution or an idea ? Thanks.

  5. #5
    Join Date
    Aug 2012
    Posts
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt resources system don't work for a simple example

    I have just discovered another big problem wich is similar too. I can't use a simple example with ui, just creating a new project with ui and directly compiling... For a ui file named "Widget.ui", after doing qmake and make, the "ui_Widget.h" file is not generated and so, I got some compilator errors that say it is impossible to find "ui_Widget.h".
    I try to build Qt sources like I did on my Linux, but it fails with this ui problem whereas I did'nt met any problem on my Linux. I am using MinGW compilator.

    It is very hopeless...
    Is there someone that have the same problems (ui or qrc, or both or other) like me or I am the only ?

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: Qt resources system don't work for a simple example

    The UI files are not processed unless they are listed in the FORMS variable of the pro file.
    If you change the PRO you need to run qmake (or your IDE has to on your behalf).

    Your last compile output shows that the resource data object file is not being linked into your application. Your first course of action is to do a clean build of the entire program including running qmake. If it still does not work in your development environment then you need to post the entire Compile output.

  7. #7
    Join Date
    Aug 2012
    Posts
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt resources system don't work for a simple example

    Yes, I know that and as I said, I created another new ui project with QtCreator wizard. Here the source files and then the compilator output :

    T.pro
    Qt Code:
    1. #-------------------------------------------------
    2. #
    3. # Project created by QtCreator 2012-08-26T23:17:02
    4. #
    5. #-------------------------------------------------
    6.  
    7. QT += core gui
    8.  
    9. greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    10.  
    11. TARGET = T
    12. TEMPLATE = app
    13.  
    14.  
    15. SOURCES += main.cpp\
    16. Widget.cpp
    17.  
    18. HEADERS += Widget.h
    19.  
    20. FORMS += Widget.ui
    To copy to clipboard, switch view to plain text mode 

    main.cpp
    Qt Code:
    1. #include <QApplication>
    2. #include "Widget.h"
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication a(argc, argv);
    7. Widget w;
    8. w.show();
    9.  
    10. return a.exec();
    11. }
    To copy to clipboard, switch view to plain text mode 

    Widget.cpp
    Qt Code:
    1. #include "Widget.h"
    2. #include "ui_Widget.h"
    3.  
    4. Widget::Widget(QWidget *parent) :
    5. QWidget(parent),
    6. ui(new Ui::Widget)
    7. {
    8. ui->setupUi(this);
    9. }
    10.  
    11. Widget::~Widget()
    12. {
    13. delete ui;
    14. }
    To copy to clipboard, switch view to plain text mode 

    Widget.ui
    Qt Code:
    1. <ui version="4.0">
    2. <class>Widget</class>
    3. <widget class="QWidget" name="Widget" >
    4. <property name="geometry" >
    5. <rect>
    6. <x>0</x>
    7. <y>0</y>
    8. <width>400</width>
    9. <height>300</height>
    10. </rect>
    11. </property>
    12. <property name="windowTitle" >
    13. <string>Widget</string>
    14. </property>
    15. </widget>
    16. <layoutDefault spacing="6" margin="11" />
    17. <pixmapfunction></pixmapfunction>
    18. <resources/>
    19. <connections/>
    20. </ui>
    To copy to clipboard, switch view to plain text mode 

    The compilator output doing the action "Rebuild the project "T" ":

    Qt Code:
    1. 09:17:09: Exécution des étapes pour le projet T...
    2. 09:17:09: Débute : "D:\Applis\Qt\mingw\bin\mingw32-make.exe" clean
    3. rm moc_Widget.cpp
    4. rm main.o Widget.o moc_Widget.o
    5. rm: cannot lstat `moc_Widget.cpp': No such file or directory
    6. mingw32-make: [compiler_moc_header_clean] Error 1 (ignored)
    7. rm: cannot lstat `Widget.o': No such file or directory
    8. rm: cannot lstat `moc_Widget.o': No such file or directory
    9. mingw32-make: [clean] Error 1 (ignored)
    10. 09:17:10: Le processus "D:\Applis\Qt\mingw\bin\mingw32-make.exe" s'est terminé normalement.
    11. 09:17:10: Configuration inchangée, étape QMake sautée.
    12. 09:17:10: Débute : "D:\Applis\Qt\mingw\bin\mingw32-make.exe"
    13. g++ -c -O2 -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I'd:/Applis/Qt/4.8.2/include/QtCore' -I'd:/Applis/Qt/4.8.2/include/QtGui' -I'd:/Applis/Qt/4.8.2/include' -I'd:/Applis/Qt/4.8.2/include/ActiveQt' -I'.' -I'd:/Applis/Qt/4.8.2/mkspecs/win32-g++' -o main.o main.cpp
    14. g++ -c -O2 -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I'd:/Applis/Qt/4.8.2/include/QtCore' -I'd:/Applis/Qt/4.8.2/include/QtGui' -I'd:/Applis/Qt/4.8.2/include' -I'd:/Applis/Qt/4.8.2/include/ActiveQt' -I'.' -I'd:/Applis/Qt/4.8.2/mkspecs/win32-g++' -o Widget.o Widget.cpp
    15. Widget.cpp:2:23: error: ui_Widget.h: No such file or directory
    16. Widget.cpp: In constructor 'Widget::Widget(QWidget*)':
    17. Widget.cpp:6: error: invalid use of incomplete type 'struct Ui::Widget'
    18. Widget.h:7: error: forward declaration of 'struct Ui::Widget'
    19. Widget.cpp:8: error: invalid use of incomplete type 'struct Ui::Widget'
    20. Widget.h:7: error: forward declaration of 'struct Ui::Widget'
    21. Widget.cpp: In destructor 'virtual Widget::~Widget()':
    22. Widget.cpp:13: warning: possible problem detected in invocation of delete operator:
    23. Widget.cpp:13: warning: invalid use of incomplete type 'struct Ui::Widget'
    24. Widget.h:7: warning: forward declaration of 'struct Ui::Widget'
    25. Widget.cpp:13: note: neither the destructor nor the class-specific operator delete will be called, even if they are declared when the class is defined.
    26. mingw32-make: *** [Widget.o] Error 1
    27. 09:17:13: Le processus "D:\Applis\Qt\mingw\bin\mingw32-make.exe" s'est terminé avec le code 2.
    28. Erreur lors de la compilation/déploiement du projet T (cible : Desktop)
    29. Lors de l'exécution de l'étape "Make"
    To copy to clipboard, switch view to plain text mode 

    I have not idea about this issue, I try to create manually in a console the ui_Widget.h and then, it works of course. The only common point is that rcc.exe et uic.exe are in the same folder but qmake.exe too ...

  8. #8
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: Qt resources system don't work for a simple example

    The compile output you show and the PRO file you show do not match. The build is not running uic because the rules are not in the Makefile. Run qmake manually to recreate Makefile and try again.

    This is what your project build looks like on my Linux machine (the MinGW commands are similar and I added your original resources for completeness):
    Qt Code:
    1. $ ls
    2. Desktop.png main.cpp resources.qrc Star.png T.pro Widget.cpp Widget.h Widget.ui
    3.  
    4. $ qmake
    5.  
    6. $ make
    7. /usr/bin/uic Widget.ui -o ui_Widget.h // <<< This is missing in your build
    8. g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -o main.o main.cpp
    9. g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -o Widget.o Widget.cpp
    10. /usr/bin/moc -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. Widget.h -o moc_Widget.cpp
    11. g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -o moc_Widget.o moc_Widget.cpp
    12. /usr/bin/rcc -name resources resources.qrc -o qrc_resources.cpp // <<< This is missing in your build
    13. g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -o qrc_resources.o qrc_resources.cpp
    14. g++ -Wl,-O1 -o T main.o Widget.o moc_Widget.o qrc_resources.o -L/usr/lib64/qt4 -lQtGui -L/usr/lib64 -L/usr/lib64/qt4 -L/usr/X11R6/lib -lQtCore -lgthread-2.0 -lrt -lglib-2.0 -lpthread
    To copy to clipboard, switch view to plain text mode 

  9. #9
    Join Date
    Aug 2012
    Posts
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt resources system don't work for a simple example

    Oh, I was explaining that I created a new project, not mixing both but it is not a problem. If you take just the last example files with ui (only by creating shown files in a folder named T), I opened a Qt console and I did what you said. Here is the compilator output, again, with the same errors :

    Qt Code:
    1. Setting up a MinGW/Qt only environment...
    2. -- QTDIR set to D:\Applis\Qt\4.8.2
    3. -- PATH set to D:\Applis\Qt\4.8.2\bin
    4. -- Adding D:\Applis\Qt\mingw\bin to PATH
    5. -- Adding C:\Windows\System32 to PATH
    6. -- QMAKESPEC set to win32-g++
    7.  
    8. D:\Applis\Qt\4.8.2>c:
    9.  
    10. C:\>cd Users\Julien\Desktop\T
    11.  
    12. C:\Users\Julien\Desktop\T>dir
    13. Le volume dans le lecteur C s'appelle ACER
    14. Le numéro de série du volume est C253-73CE
    15.  
    16. Répertoire de C:\Users\Julien\Desktop\T
    17.  
    18. 27/08/2012 11:28 <REP> .
    19. 27/08/2012 11:28 <REP> ..
    20. 26/08/2012 23:17 179 main.cpp
    21. 27/08/2012 09:18 362 T.pro
    22. 26/08/2012 23:17 201 Widget.cpp
    23. 26/08/2012 23:17 317 Widget.h
    24. 26/08/2012 23:17 441 Widget.ui
    25. 5 fichier(s) 1*500 octets
    26. 2 Rép(s) 14*285*438*976 octets libres
    27.  
    28. C:\Users\Julien\Desktop\T>qmake
    29. d:\Applis\Qt\4.8.2\mkspecs\features\debug_and_release.prf:1: Unknown test functi
    30. on: addExclusiveBuilds
    31.  
    32. C:\Users\Julien\Desktop\T>make
    33. g++ -c -frtti -fexceptions -mthreads -g -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -
    34. DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -
    35. DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"d:\Applis
    36. \Qt\4.8.2\include\QtCore" -I"d:\Applis\Qt\4.8.2\include\QtGui" -I"d:\Applis\Qt\4
    37. .8.2\include" -I"d:\Applis\Qt\4.8.2\include\ActiveQt" -I"." -I"d:\Applis\Qt\4.8.
    38. 2\mkspecs\win32-g++" -o main.o main.cpp
    39. g++ -c -frtti -fexceptions -mthreads -g -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -
    40. DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -
    41. DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"d:\Applis
    42. \Qt\4.8.2\include\QtCore" -I"d:\Applis\Qt\4.8.2\include\QtGui" -I"d:\Applis\Qt\4
    43. .8.2\include" -I"d:\Applis\Qt\4.8.2\include\ActiveQt" -I"." -I"d:\Applis\Qt\4.8.
    44. 2\mkspecs\win32-g++" -o Widget.o Widget.cpp
    45. Widget.cpp:2:23: error: ui_Widget.h : No such file or directory
    46. Widget.cpp: In constructor 'Widget::Widget(QWidget*)':
    47. Widget.cpp:6: erreur: invalid use of incomplete type 'struct Ui::Widget'
    48. Widget.h:7: erreur: forward declaration of 'struct Ui::Widget'
    49. Widget.cpp:8: erreur: invalid use of incomplete type 'struct Ui::Widget'
    50. Widget.h:7: erreur: forward declaration of 'struct Ui::Widget'
    51. Widget.cpp: In destructor 'virtual Widget::~Widget()':
    52. Widget.cpp:13: attention : problème possible détecté dans l'invocation de l'opér
    53. ateur delete:
    54. Widget.cpp:13: attention : invalid use of incomplete type 'struct Ui::Widget'
    55. Widget.h:7: attention : forward declaration of 'struct Ui::Widget'
    56. Widget.cpp:13: note: neither the destructor nor the class-specific operator dele
    57. te will be called, even if they are declared when the class is defined.
    58. mingw32-make: *** [Widget.o] Error 1
    59.  
    60. C:\Users\Julien\Desktop\T>
    To copy to clipboard, switch view to plain text mode 

    I don't know if it can help but I give the generated Makefile below :
    Qt Code:
    1. #############################################################################
    2. # Makefile for building: T
    3. # Generated by qmake (2.01a) (Qt 4.8.2) on: lun. 27. août 11:28:57 2012
    4. # Project: T.pro
    5. # Template: app
    6. # Command: d:\Applis\Qt\4.8.2\bin\qmake.exe -o Makefile T.pro
    7. #############################################################################
    8.  
    9. ####### Compiler, tools and options
    10.  
    11. CC = gcc
    12. CXX = g++
    13. DEFINES = -DUNICODE -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 -DQT_NEEDS_QMAIN
    14. CFLAGS = -g -Wall $(DEFINES)
    15. CXXFLAGS = -frtti -fexceptions -mthreads -g -Wall $(DEFINES)
    16. INCPATH = -I"d:\Applis\Qt\4.8.2\include\QtCore" -I"d:\Applis\Qt\4.8.2\include\QtGui" -I"d:\Applis\Qt\4.8.2\include" -I"d:\Applis\Qt\4.8.2\include\ActiveQt" -I"." -I"d:\Applis\Qt\4.8.2\mkspecs\win32-g++"
    17. LINK = g++
    18. LFLAGS = -mthreads -Wl,-subsystem,windows
    19. LIBS = -L"d:\Applis\Qt\4.8.2\lib" -lmingw32 -lqtmaind -lQtGui4 -lQtCore4
    20. QMAKE = d:\Applis\Qt\4.8.2\bin\qmake.exe
    21. IDC = d:\Applis\Qt\4.8.2\bin\idc.exe
    22. IDL = midl
    23. ZIP = zip -r -9
    24. DEF_FILE =
    25. RES_FILE =
    26. COPY = copy /y
    27. SED =
    28. COPY_FILE = $(COPY)
    29. COPY_DIR = xcopy /s /q /y /i
    30. DEL_FILE = del
    31. DEL_DIR = rmdir
    32. MOVE = move
    33. CHK_DIR_EXISTS= if not exist
    34. MKDIR = mkdir
    35. INSTALL_FILE = $(COPY_FILE)
    36. INSTALL_PROGRAM = $(COPY_FILE)
    37. INSTALL_DIR = $(COPY_DIR)
    38.  
    39. ####### Output directory
    40.  
    41. OBJECTS_DIR = .
    42.  
    43. ####### Files
    44.  
    45. SOURCES = main.cpp \
    46. Widget.cpp moc_Widget.cpp
    47. OBJECTS = main.o \
    48. Widget.o \
    49. moc_Widget.o
    50. DIST =
    51. QMAKE_TARGET = T
    52. DESTDIR = #avoid trailing-slash linebreak
    53. TARGET = T.exe
    54. DESTDIR_TARGET = T.exe
    55.  
    56. ####### Implicit rules
    57.  
    58. .SUFFIXES: .cpp .cc .cxx .c
    59.  
    60. .cpp.o:
    61. $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
    62.  
    63. .cc.o:
    64. $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
    65.  
    66. .cxx.o:
    67. $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
    68.  
    69. .c.o:
    70. $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
    71.  
    72. ####### Build rules
    73.  
    74. first: all
    75. all: Makefile $(DESTDIR_TARGET)
    76.  
    77. $(DESTDIR_TARGET): $(OBJECTS)
    78. $(LINK) $(LFLAGS) -o $(DESTDIR_TARGET) $(OBJECTS) $(LIBS)
    79.  
    80. Makefile: T.pro d:/Applis/Qt/4.8.2/mkspecs/win32-g++/qmake.conf d:/Applis/Qt/4.8.2/mkspecs/qconfig.pri \
    81. d:/Applis/Qt/4.8.2/mkspecs/modules/qt_webkit_version.pri \
    82. d:/Applis/Qt/4.8.2/mkspecs/features/qt_functions.prf \
    83. d:/Applis/Qt/4.8.2/mkspecs/features/qt_config.prf \
    84. d:/Applis/Qt/4.8.2/mkspecs/features/win32/default_pre.prf \
    85. d:/Applis/Qt/4.8.2/mkspecs/features/win32/default_post.prf \
    86. d:/Applis/Qt/4.8.2/mkspecs/features/win32/rtti.prf \
    87. d:/Applis/Qt/4.8.2/mkspecs/features/win32/exceptions.prf \
    88. d:/Applis/Qt/4.8.2/mkspecs/features/win32/stl.prf \
    89. d:/Applis/Qt/4.8.2/mkspecs/features/shared.prf \
    90. d:/Applis/Qt/4.8.2/mkspecs/features/debug.prf \
    91. d:/Applis/Qt/4.8.2/mkspecs/features/debug_and_release.prf \
    92. d:/Applis/Qt/4.8.2/mkspecs/features/warn_on.prf \
    93. d:/Applis/Qt/4.8.2/mkspecs/features/qt.prf \
    94. d:/Applis/Qt/4.8.2/mkspecs/features/win32/thread.prf \
    95. d:/Applis/Qt/4.8.2/mkspecs/features/moc.prf \
    96. d:/Applis/Qt/4.8.2/mkspecs/features/win32/windows.prf \
    97. d:/Applis/Qt/4.8.2/mkspecs/features/include_source_dir.prf \
    98. d:/Applis/Qt/4.8.2/lib/qtmaind.prl
    99. $(QMAKE) -o Makefile T.pro
    100. d:\Applis\Qt\4.8.2\mkspecs\qconfig.pri:
    101. d:\Applis\Qt\4.8.2\mkspecs\modules\qt_webkit_version.pri:
    102. d:\Applis\Qt\4.8.2\mkspecs\features\qt_functions.prf:
    103. d:\Applis\Qt\4.8.2\mkspecs\features\qt_config.prf:
    104. d:\Applis\Qt\4.8.2\mkspecs\features\win32\default_pre.prf:
    105. d:\Applis\Qt\4.8.2\mkspecs\features\win32\default_post.prf:
    106. d:\Applis\Qt\4.8.2\mkspecs\features\win32\rtti.prf:
    107. d:\Applis\Qt\4.8.2\mkspecs\features\win32\exceptions.prf:
    108. d:\Applis\Qt\4.8.2\mkspecs\features\win32\stl.prf:
    109. d:\Applis\Qt\4.8.2\mkspecs\features\shared.prf:
    110. d:\Applis\Qt\4.8.2\mkspecs\features\debug.prf:
    111. d:\Applis\Qt\4.8.2\mkspecs\features\debug_and_release.prf:
    112. d:\Applis\Qt\4.8.2\mkspecs\features\warn_on.prf:
    113. d:\Applis\Qt\4.8.2\mkspecs\features\qt.prf:
    114. d:\Applis\Qt\4.8.2\mkspecs\features\win32\thread.prf:
    115. d:\Applis\Qt\4.8.2\mkspecs\features\moc.prf:
    116. d:\Applis\Qt\4.8.2\mkspecs\features\win32\windows.prf:
    117. d:\Applis\Qt\4.8.2\mkspecs\features\include_source_dir.prf:
    118. d:\Applis\Qt\4.8.2\lib\qtmaind.prl:
    119. qmake: FORCE
    120. @$(QMAKE) -o Makefile T.pro
    121.  
    122. dist:
    123. $(ZIP) T.zip $(SOURCES) $(DIST) T.pro d:\Applis\Qt\4.8.2\mkspecs\qconfig.pri d:\Applis\Qt\4.8.2\mkspecs\modules\qt_webkit_version.pri d:\Applis\Qt\4.8.2\mkspecs\features\qt_functions.prf d:\Applis\Qt\4.8.2\mkspecs\features\qt_config.prf d:\Applis\Qt\4.8.2\mkspecs\features\win32\default_pre.prf d:\Applis\Qt\4.8.2\mkspecs\features\win32\default_post.prf d:\Applis\Qt\4.8.2\mkspecs\features\win32\rtti.prf d:\Applis\Qt\4.8.2\mkspecs\features\win32\exceptions.prf d:\Applis\Qt\4.8.2\mkspecs\features\win32\stl.prf d:\Applis\Qt\4.8.2\mkspecs\features\shared.prf d:\Applis\Qt\4.8.2\mkspecs\features\debug.prf d:\Applis\Qt\4.8.2\mkspecs\features\debug_and_release.prf d:\Applis\Qt\4.8.2\mkspecs\features\warn_on.prf d:\Applis\Qt\4.8.2\mkspecs\features\qt.prf d:\Applis\Qt\4.8.2\mkspecs\features\win32\thread.prf d:\Applis\Qt\4.8.2\mkspecs\features\moc.prf d:\Applis\Qt\4.8.2\mkspecs\features\win32\windows.prf d:\Applis\Qt\4.8.2\mkspecs\features\include_source_dir.prf d:\Applis\Qt\4.8.2\lib\qtmaind.prl HEADERS SOURCES OBJECTIVE_SOURCES
    124.  
    125. clean: compiler_clean
    126. -$(DEL_FILE) main.o Widget.o moc_Widget.o
    127.  
    128. distclean: clean
    129. -$(DEL_FILE) $(DESTDIR_TARGET)
    130. -$(DEL_FILE) Makefile
    131.  
    132. mocclean: compiler_moc_header_clean compiler_moc_source_clean
    133.  
    134. mocables: compiler_moc_header_make_all compiler_moc_source_make_all
    135.  
    136. compiler_moc_header_make_all: moc_Widget.cpp
    137. compiler_moc_header_clean:
    138. -$(DEL_FILE) moc_Widget.cpp
    139. moc_Widget.cpp: Widget.h
    140. D:\Applis\Qt\4.8.2\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 Widget.h -o moc_Widget.cpp
    141.  
    142. compiler_moc_source_make_all:
    143. compiler_moc_source_clean:
    144. compiler_clean: compiler_moc_header_clean
    145.  
    146.  
    147.  
    148. ####### Compile
    149.  
    150. main.o: main.cpp Widget.h
    151. $(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp
    152.  
    153. Widget.o: Widget.cpp Widget.h
    154. $(CXX) -c $(CXXFLAGS) $(INCPATH) -o Widget.o Widget.cpp
    155.  
    156. moc_Widget.o: moc_Widget.cpp
    157. $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_Widget.o moc_Widget.cpp
    158.  
    159. ####### Install
    160.  
    161. install: FORCE
    162.  
    163. uninstall: FORCE
    164.  
    165. FORCE:
    To copy to clipboard, switch view to plain text mode 

    EDIT: Do you want to see the output on my Linux with the same project ? I don't try but I'm sure it works.
    Last edited by P'tit Ju; 27th August 2012 at 11:41.

  10. #10
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: Qt resources system don't work for a simple example

    These errors:
    Qt Code:
    1. C:\Users\Julien\Desktop\T>qmake
    2. d:\Applis\Qt\4.8.2\mkspecs\features\debug_and_release.prf:1: Unknown test function: addExclusiveBuilds
    To copy to clipboard, switch view to plain text mode 
    indicate that there is something broken in your Qt install itself. The missing function is defined in "mkspecs/features/exclusive_builds.prf", so see if that file is present or corrupt. You may need to reinstall Qt if the file has become corrupted.

  11. #11
    Join Date
    Aug 2012
    Posts
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt resources system don't work for a simple example

    Ok, thank you for this advise but this file doesn't seem corrupt. I don't know if it is necessary giving you contents file :

    Qt Code:
    1. # fixExclusiveOutputDirs(1config, 2config)
    2. # Change all output paths that references 2config to have the string 1config in them
    3. defineTest(fixExclusiveOutputDirs) {
    4. unset(firstBuild)
    5. unset(secondBuild)
    6. unset(appendFirstBuild)
    7. firstBuild = $$1
    8. secondBuild = $$2
    9. count(ARGS, 2, greaterThan):isEqual($$list($$lower($$3)), false):appendFirstBuild = false
    10. else:appendFirstBuild = true
    11.  
    12. isEmpty(QMAKE_DIR_REPLACE):QMAKE_DIR_REPLACE += OBJECTS_DIR MOC_DIR RCC_DIR
    13. lessThan(firstBuild, $$secondBuild):eval($${firstBuild}_and_$${secondBuild}_target:QMAKE_DIR_REPLACE += DESTDIR)
    14. else:eval($${secondBuild}_and_$${firstBuild}_target:QMAKE_DIR_REPLACE += DESTDIR)
    15. for(fix, QMAKE_DIR_REPLACE) {
    16. isEmpty($$fix)|isEqual($$fix, .) {
    17. eval($$fix = $${firstBuild})
    18. } else:contains($$list($$first($$fix)), .*$${secondBuild}.*) {
    19. eval($$fix ~= s/$${secondBuild}/$${firstBuild}/gi)
    20. } else:isEqual(appendFirstBuild, true):!contains($$list($$first($$fix)), .*$${firstBuild}.*) {
    21. contains($$list($${first($$fix)}), .*/$):eval($$fix = $${first($$fix)}$${firstBuild})
    22. else:eval($$fix = $${first($$fix)}-$${firstBuild})
    23. }
    24. export($$fix)
    25. }
    26. return(true)
    27. }
    28.  
    29. # addExclusiveBuilds(1config, 1name, 2config, 2name)
    30. # Adds two BUILDS which are exclusive to each other.
    31. defineTest(addExclusiveBuilds) {
    32. unset(firstBuild)
    33. unset(firstBuildName)
    34. unset(secondBuild)
    35. unset(secondBuildName)
    36.  
    37. firstBuild = $$1
    38. firstBuildName = $$2
    39. secondBuild = $$3
    40. secondBuildName = $$4
    41.  
    42. contains(TEMPLATE, subdirs) {
    43. eval(sub_$${firstBuildName}.target = $$firstBuild)
    44. export(sub_$${firstBuildName}.target)
    45. eval(sub_$${firstBuildName}.CONFIG = recursive)
    46. export(sub_$${firstBuildName}.CONFIG)
    47. eval(sub_$${secondBuildName}.target = $$secondBuild)
    48. export(sub_$${secondBuildName}.target)
    49. eval(sub_$${secondBuildName}.CONFIG = recursive)
    50. export(sub_$${secondBuildName}.CONFIG)
    51. QMAKE_EXTRA_TARGETS += sub_$${firstBuildName} sub_$${secondBuildName}
    52. export(QMAKE_EXTRA_TARGETS)
    53. } else:!build_pass {
    54. first_BUILDS =
    55. second_BUILDS =
    56. suffix_BUILDS = Build
    57.  
    58. isEmpty(BUILDS): BUILDPERMUTATIONS = $$suffix_BUILDS
    59. else: BUILDPERMUTATIONS = $$BUILDS
    60.  
    61. for(permutation, BUILDPERMUTATIONS) {
    62. permutation ~= s/$${suffix_BUILDS}$//
    63. isEmpty(permutation): permutationName =
    64. else: permutationName = -$$permutation
    65. # Makefile target rule
    66. eval($${firstBuildName}$${permutation}.target = $${firstBuild}$$lower($${permutationName}))
    67. export($${firstBuildName}$${permutation}.target)
    68. # IDE name
    69. eval($${firstBuildName}$${permutation}.name = $${firstBuildName}$${permutationName})
    70. export($${firstBuildName}$${permutation}.name)
    71. # prl import CONFIG option
    72. eval($${firstBuildName}$${permutation}.PRL_CONFIG = $${firstBuild}$${permutation})
    73. export($${firstBuildName}$${permutation}.PRL_CONFIG)
    74. # Individual CONFIG option
    75. eval($${firstBuildName}$${permutation}.CONFIG = $${firstBuild} $${firstBuildName}Build $$eval($${permutation}.CONFIG))
    76. export($${firstBuildName}$${permutation}.CONFIG)
    77.  
    78. eval($${secondBuildName}$${permutation}.target = $${secondBuild}$$lower($${permutationName}))
    79. export($${secondBuildName}$${permutation}.target)
    80. eval($${secondBuildName}$${permutation}.name = $${secondBuildName}$${permutationName})
    81. export($${secondBuildName}$${permutation}.name)
    82. eval($${secondBuildName}$${permutation}.PRL_CONFIG = $${secondBuild}$${permutation})
    83. export($${secondBuildName}$${permutation}.PRL_CONFIG)
    84. eval($${secondBuildName}$${permutation}.CONFIG = $${secondBuild} $${secondBuildName}Build $$eval($${permutation}.CONFIG))
    85. export($${secondBuildName}$${permutation}.CONFIG)
    86.  
    87. first_BUILDS += $${firstBuildName}$${permutation}
    88. second_BUILDS += $${secondBuildName}$${permutation}
    89. }
    90.  
    91. # A mutual exclusive block.
    92. CONFIG($${firstBuild}, $${firstBuild}|$${secondBuild}): BUILDS = $$first_BUILDS $$second_BUILDS
    93. else: BUILDS = $$second_BUILDS $$first_BUILDS
    94. export(BUILDS)
    95. } else {
    96. eval($${firstBuildName}Build:fixExclusiveOutputDirs($$firstBuild, $$secondBuild, false))
    97. eval($${secondBuildName}Build:fixExclusiveOutputDirs($$secondBuild, $$firstBuild, false))
    98. }
    99. return(true)
    100. }
    To copy to clipboard, switch view to plain text mode 

    Maybe this file is not read and so, the function is unknown.

Similar Threads

  1. QIcons, sharing system resources on Windows
    By markfinal in forum Qt Programming
    Replies: 0
    Last Post: 24th August 2010, 13:04
  2. Replies: 3
    Last Post: 15th February 2010, 12:44
  3. Replies: 12
    Last Post: 5th July 2009, 17:03
  4. surprise why this simple statement doesnt work
    By salmanmanekia in forum Qt Programming
    Replies: 6
    Last Post: 28th July 2008, 13:42
  5. QHttp simple program doesn't work
    By johncharlesb in forum Qt Programming
    Replies: 0
    Last Post: 4th April 2008, 05:18

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
  •  
Qt is a trademark of The Qt Company.