Hi everyone,

I'm migrating an old (well, really ancient) Windows application from Borland Builder 3 to Qt. I've started creating a new project, particularly a Qt Gui application. I've used as an example the editabletreemodel project included in the demos. Hence, the project includes simply a form (that I've renamed as VFIT_W) and a main file. Well, first of all I've created a menu bar (with no operative options; just to see the menu options) and (reading help everywhere) a status bar. While I designed this useless form, I've been able to compile and run the application.

The problem has appeared when I've tried to activate the first option of the menu bar: Exit. I've written a simple function called ExitClick, and connected this function to Exit QAction. However, a compiler error appears. Can anyone tell me where's the mistake, please?

The form code looks like this. This are the elements in the main window (basically the menu bar, as the status bar has been generated in the constructor):

Form.png

This is the header of the main window (VFIT_W.h file):

Qt Code:
  1. #ifndef VFIT_W_H
  2. #define VFIT_W_H
  3.  
  4. #include <QMainWindow>
  5. #include <QLabel>
  6.  
  7. namespace Ui {
  8. class VFITW;
  9. }
  10.  
  11. class VFITW : public QMainWindow
  12. {
  13. Q_OBJECT
  14.  
  15. public:
  16. explicit VFITW(QWidget *parent = 0);
  17. ~VFITW();
  18.  
  19. private:
  20. Ui::VFITW *ui;
  21. QLabel *st_1, *st_2, *st_3;
  22.  
  23. private slots:
  24. void ExitClick();
  25. };
  26.  
  27. #endif // VFIT_W_H
To copy to clipboard, switch view to plain text mode 

This is the code of the main window (VFIT_W.cpp file):

Qt Code:
  1. #include <QtGui>
  2. #include <QWidget>
  3. #include <QAction>
  4.  
  5. #include "VFIT_W.h"
  6. #include "ui_VFIT_W.h"
  7.  
  8. VFITW::VFITW(QWidget *parent) :
  9. QMainWindow(parent),
  10. ui(new Ui::VFITW)
  11. {
  12. ui->setupUi(this);
  13.  
  14. // Show main window maximized
  15. this->setWindowState(Qt::WindowMaximized);
  16.  
  17. // Create status bar
  18. st_1 = new QLabel("Left", this);
  19. st_1->setMinimumSize(150, 20);
  20. st_1->setMaximumSize(500, 20);
  21. st_1->setFrameStyle(QFrame::Panel | QFrame::Sunken);
  22. st_1->setAlignment(Qt::AlignCenter | Qt::AlignRight);
  23. st_1->setWhatsThis("Info left");
  24. st_2 = new QLabel("Middle", this);
  25. st_2->setMinimumSize(450, 20);
  26. st_2->setFrameStyle(QFrame::Panel | QFrame::Sunken);
  27. st_2->setAlignment(Qt::AlignCenter | Qt::AlignRight);
  28. st_2->setWhatsThis("Info middle");
  29. st_3 = new QLabel("Right", this);
  30. st_3->setMinimumSize(700, 20);
  31. st_3->setFrameStyle(QFrame::Panel | QFrame::Sunken);
  32. st_3->setAlignment(Qt::AlignCenter | Qt::AlignRight);
  33. st_3->setWhatsThis("Info right");
  34.  
  35. statusBar()->addPermanentWidget(st_1, 0);
  36. statusBar()->addPermanentWidget(st_2, 0);
  37. statusBar()->addPermanentWidget(st_3, 100);
  38.  
  39. connect(Exit, SIGNAL(triggered()), qApp, SLOT(ExitClick()));
  40.  
  41. }
  42.  
  43. VFITW::~VFITW()
  44. {
  45. delete ui;
  46. }
  47.  
  48. void VFITW::ExitClick()
  49. {
  50. exit(EXIT_SUCCESS);
  51. }
To copy to clipboard, switch view to plain text mode 

The error (error: 'Exit' was not declared in this scope) refers to the "connect" code line. In the editabletreemodel project that I've used as a model, the connection of the "exit" option of the main menu is made exactly the same (although the names of both the QAction and the function are different).

On the other hand, I've kept the code related to the creation of the status bar because I also have a small problem with the "WhatsThis" messages in the status bar: they don't appear. I haven't seen anywhere if I need to activate or configure this property so I don't understand why they don't become visible.

Finally, this is the code of the main.cpp file:

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

There are many differences from Builder 3, and I don't understand much of the automatic code generated (like "#include "ui_VFIT_W.h" " in the VFITW.cpp file...), but I hope to end up to manage. I wish there was an application which would "translate" code from Builder 3 to Qt! . Meanwhile, I'll have to do my best on my own or with some help...

Thanks a lot!