Hi,

Maybe too much hours working, maybe I have been looking the code for too much time, maybe I don't understand exactly the documentation, or maybe there are no error, but I have some memory leaks with this code and I feel unable to find a solution. I'm trying to load from a ui file a QMainWindow.

Qt Code:
  1. #include <QApplication>
  2. #include <QTranslator>
  3. #include <QObject>
  4. #include <QUiLoader>
  5. #include <QFile>
  6.  
  7. int main(int argc, char *argv[])
  8. {
  9. QMainDlg *mainWin = 0;
  10.  
  11. QApplication app(argc, argv);
  12.  
  13. // Cargamos el archivo con las traducciones
  14. QTranslator translator;
  15. if (translator.load("qt_es", app.applicationDirPath()) == false) {
  16. QMessageBox::warning(0, QString::fromUtf8(APP_NAME),
  17. QObject::trUtf8("Ha sido imposible cargar el fichero con las traducciones."));
  18. } else {
  19. app.installTranslator(&translator);
  20. }
  21.  
  22. QString fileName = QString("/home/david/tmp/main.qmaindlg.ui");
  23. QUiLoader uiLoader;
  24.  
  25. if ( QFile::exists(fileName) ) {
  26. QFile file (fileName);
  27. file.open( QFile::ReadOnly );
  28. QWidget *wid = uiLoader.load(&file, 0);
  29. if ( wid != NULL ) {
  30. wid->setAttribute(Qt::WA_DeleteOnClose);
  31. wid->show();
  32. }
  33. file.close();
  34. bool rc = app.exec();
  35. return rc;
  36. }
  37. }
To copy to clipboard, switch view to plain text mode 

I simplify the main.qmaindlg.ui file to this:

Qt Code:
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <ui version="4.0">
  3. <class>QMainDlg</class>
  4. <widget class="QMainWindow" name="QMainDlg">
  5. <property name="geometry">
  6. <rect>
  7. <x>0</x>
  8. <y>0</y>
  9. <width>790</width>
  10. <height>126</height>
  11. </rect>
  12. </property>
  13. <property name="windowTitle">
  14. <string>Presupuestos - Pinelo Talleres Gráficos</string>
  15. </property>
  16. <property name="windowIcon">
  17. <iconset>
  18. <normaloff>:/aplicacion/recursos/icono_app_peque.png</normaloff>:/aplicacion/recursos/icono_app_peque.png</iconset>
  19. </property>
  20. <widget class="QWidget" name="centralwidget"/>
  21. </widget>
  22. <connections/>
  23. </ui>
To copy to clipboard, switch view to plain text mode 

I use the Qt47supp.txt provides on Nokia Labs... The output of Valgrind is attached. You can see a lot of "definitely lost". valgrind.output.txt.zip

Is this normal? Something wrong with my code? I have no idea and I have several crashes on my applications, related with this, I think.

Thanks a lot.