Thank you wysota for your reply.

But could you please be more specific?

Someone suggested me with the following code:
Qt Code:
  1. int Dlg::exec()
  2. {
  3. functionToBeCalled();
  4. return QDialog::exec();
  5. }
To copy to clipboard, switch view to plain text mode 
but the problem is that, my functionToBeCalled() is a function that does some animation (inside a QGraphicsView), so if we call this function before the exec() function, the user will not see the animation.
I have got an idea but could not make it work. In the following code, I re-implement completely the exec() function, by just copying the source code of QDialog::exec() and adding functionToBeCalled() after show():
Qt Code:
  1. int Dlg::exec()
  2. {
  3. Q_D(QDialog);
  4.  
  5. if (d->eventLoop) {
  6. qWarning("QDialog::exec: Recursive call detected");
  7. return -1;
  8. }
  9.  
  10. bool deleteOnClose = testAttribute(Qt::WA_DeleteOnClose);
  11. setAttribute(Qt::WA_DeleteOnClose, false);
  12.  
  13. d->resetModalitySetByOpen();
  14.  
  15. bool wasShowModal = testAttribute(Qt::WA_ShowModal);
  16. setAttribute(Qt::WA_ShowModal, true);
  17. setResult(0);
  18.  
  19. //On Windows Mobile we create an empty menu to hide the current menu
  20. #ifdef Q_WS_WINCE_WM
  21. #ifndef QT_NO_MENUBAR
  22. QMenuBar *menuBar = 0;
  23. if (!findChild<QMenuBar *>())
  24. menuBar = new QMenuBar(this);
  25. if (qt_wince_is_smartphone()) {
  26. QAction *doneAction = new QAction(tr("Done"), this);
  27. menuBar->setDefaultAction(doneAction);
  28. connect(doneAction, SIGNAL(triggered()), this, SLOT(_q_doneAction()));
  29. }
  30. #endif //QT_NO_MENUBAR
  31. #endif //Q_WS_WINCE_WM
  32.  
  33. bool showSystemDialogFullScreen = false;
  34. #ifdef Q_OS_SYMBIAN
  35. if (qobject_cast<QFileDialog *>(this) || qobject_cast<QFontDialog *>(this) ||
  36. qobject_cast<QWizard *>(this)) {
  37. showSystemDialogFullScreen = true;
  38. }
  39. #endif // Q_OS_SYMBIAN
  40.  
  41. if (showSystemDialogFullScreen) {
  42. setWindowFlags(windowFlags() | Qt::WindowSoftkeysVisibleHint);
  43. setWindowState(Qt::WindowFullScreen);
  44. }
  45. show();
  46.  
  47. /****** MY ANIMATION HERE *******/
  48. functionToBeCalled();
  49.  
  50. #ifdef Q_WS_MAC
  51. d->mac_nativeDialogModalHelp();
  52. #endif
  53.  
  54. QEventLoop eventLoop;
  55. d->eventLoop = &eventLoop;
  56. QPointer<QDialog> guard = this;
  57. (void) eventLoop.exec(QEventLoop::DialogExec);
  58. if (guard.isNull())
  59. return QDialog::Rejected;
  60. d->eventLoop = 0;
  61.  
  62. setAttribute(Qt::WA_ShowModal, wasShowModal);
  63.  
  64. int res = result();
  65. if (deleteOnClose)
  66. delete this;
  67. #ifdef Q_WS_WINCE_WM
  68. #ifndef QT_NO_MENUBAR
  69. else if (menuBar)
  70. delete menuBar;
  71. #endif //QT_NO_MENUBAR
  72. #endif //Q_WS_WINCE_WM
  73. return res;
  74. }
To copy to clipboard, switch view to plain text mode 
The first error I got is _'QDialog::d_func' : cannot access private member declared in class 'QDialog'_.
Hope somebody can help.
Have a nice day !