jcbaraza
30th June 2012, 12:47
Hi everyone,
I'm migrating an ancient application from Borland Builder 3 to Qt4. In Builder, there exists an extensive management of events in VCL classes. When designing VCL classes, besides the constructor and destroy functions, lots of event managing functions associated to every object in the form can be implemented. Every kind of objects (labels, buttons, lists, the keyboard, the mouse, and even the main form) have their own set of associated events: OnEnter, On Change, OnClick, OnKeyDown, etc.
In the particular case of the main form, there exists an event called "FormActivate" (managed by an event manager called "OnFormActivate"), which is launched after the form has been created and made visible, and just before the user can take control (i.e., to push keys or click the mouse). In this event manager, it is possible to make some tasks like configuration (loading configuration from files, o auto-configure the application), showing additional windows (info or dialogs), fulfilling the fields of the main form, and so on.
Well, for the last days I've been trying to find in Qt a SIGNAL in QMainWindow class equivalent to Builder's "FormActivateE event, in order to CONNECT my former "OnFormActivate" Builder function (adapted of course) to to such signal, and thus do in the same way as in Builder. However, I haven't found any equivalent nor similar signal. What I've found is a QEvent called "WindowActivate". So, I've thought that I could to create my own signal when "WindowActivate" is shot.
After reading Qt handbooks and Molkentin's "The Book of Qt 4 - The art of building Qt applications", I've "learnt" that I should use general event() event handler, and there capture the corresponding event and generate a custom "FormActivate" signal, to be connected to "OnFormActivate" method/function. However, when I've written in the header of my main window class the declaration of the event handler I've got a compilation error:
#ifndef VFIT_W_H
#define VFIT_W_H
#include <QMainWindow>
#include <QLabel>
#include <QActionGroup>
#include <QEvent>
namespace Ui {
class VFITW;
}
class VFITW : public QMainWindow
{
Q_OBJECT
public:
explicit VFITW(QWidget *parent = 0);
~VFITW();
private:
Ui::VFITW *ui;
...
bool event(QEvent *e);
...
public slots:
...
private slots:
void FormActivate(); // This is the slot which will manage the WindowActivate event
...
};
#endif // VFIT_W_H
The error is error: collect2: ld returned 1 exit status. What am I doing wrong? Am I forgetting anything? Is there another option (easier than managing QEvents ;-P) to emulate my "FormActivate" Builder event?
Thanks a lot in advance!
I'm migrating an ancient application from Borland Builder 3 to Qt4. In Builder, there exists an extensive management of events in VCL classes. When designing VCL classes, besides the constructor and destroy functions, lots of event managing functions associated to every object in the form can be implemented. Every kind of objects (labels, buttons, lists, the keyboard, the mouse, and even the main form) have their own set of associated events: OnEnter, On Change, OnClick, OnKeyDown, etc.
In the particular case of the main form, there exists an event called "FormActivate" (managed by an event manager called "OnFormActivate"), which is launched after the form has been created and made visible, and just before the user can take control (i.e., to push keys or click the mouse). In this event manager, it is possible to make some tasks like configuration (loading configuration from files, o auto-configure the application), showing additional windows (info or dialogs), fulfilling the fields of the main form, and so on.
Well, for the last days I've been trying to find in Qt a SIGNAL in QMainWindow class equivalent to Builder's "FormActivateE event, in order to CONNECT my former "OnFormActivate" Builder function (adapted of course) to to such signal, and thus do in the same way as in Builder. However, I haven't found any equivalent nor similar signal. What I've found is a QEvent called "WindowActivate". So, I've thought that I could to create my own signal when "WindowActivate" is shot.
After reading Qt handbooks and Molkentin's "The Book of Qt 4 - The art of building Qt applications", I've "learnt" that I should use general event() event handler, and there capture the corresponding event and generate a custom "FormActivate" signal, to be connected to "OnFormActivate" method/function. However, when I've written in the header of my main window class the declaration of the event handler I've got a compilation error:
#ifndef VFIT_W_H
#define VFIT_W_H
#include <QMainWindow>
#include <QLabel>
#include <QActionGroup>
#include <QEvent>
namespace Ui {
class VFITW;
}
class VFITW : public QMainWindow
{
Q_OBJECT
public:
explicit VFITW(QWidget *parent = 0);
~VFITW();
private:
Ui::VFITW *ui;
...
bool event(QEvent *e);
...
public slots:
...
private slots:
void FormActivate(); // This is the slot which will manage the WindowActivate event
...
};
#endif // VFIT_W_H
The error is error: collect2: ld returned 1 exit status. What am I doing wrong? Am I forgetting anything? Is there another option (easier than managing QEvents ;-P) to emulate my "FormActivate" Builder event?
Thanks a lot in advance!