Re: About signals and events
May be you've not declared that event function in your header file. You've to specify it there. and also, you've to implement the definition of that event in your source file. I can't able to figure the error with this code. Place your source file here, then only we could figure out what is the problem...
Re: About signals and events
Hi,
First of all, thanks for your answer. When copying the source code in the post I've realized what was the cause of the compilation error: I didn't uncomment the code of the event manager event().
The problem now is to know when the main window becomes active after creation. As I mentionned in my previous post, there exist in Builder a set of predefined event handler for every VCL object. In forms, there is one particularly intresting to me, called "OnFormActivate", which runs when the event "FormActivate" shots. This happens after the form (window) is created and made visible, but still is unavailable for the user. Within this event it is possible to perform configuration tasks, and show status messages and launch dialogs. Most of these configuration tasks actually could be performed by the constructor, but the window would not be visible yet (at least, I think so...). That's why I want to know the moment of the form activation. Moreover, as my original Builder program uses several custom forms that I fulfill online, I repeat this process many times.
I include the source code of the main window just in case.
That's the header of the main window:
Quote:
#ifndef VFIT_W_H
#define VFIT_W_H
#include <QMainWindow>
#include <QLabel>
#include <QActionGroup>
#include <QEvent>
#include "GStrings.h"
namespace Ui {
class VFITW;
}
class VFITW : public QMainWindow
{
Q_OBJECT
public:
explicit VFITW(QWidget *parent = 0);
~VFITW();
private:
Ui::VFITW *ui;
...
void event(QEvent *e);
private slots:
void OnFormActivate();
...
};
#endif // VFIT_W_H
And that's the source code of the main window:
Quote:
#include <QtGui>
#include <QWidget>
#include <QAction>
...
#include "VFIT_W.h"
#include "ui_VFIT_W.h"
VFITW::VFITW(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::VFITW)
{
ui->setupUi(this);
// This will be the future connection of OnFormActivate private slot to the custom signal FormActivate (still to be defined)
// connect(this, SIGNAL(FormActivate()), this, SLOT(OnFormActivate()));
...
}
VFITW::~VFITW()
{
delete ui;
}
...
void VFITW::event(QEvent *e)
{
// It's still empty...
}
...
void VFITW::OnFormActivate()
{
if (Initialized)
return ;
Initialized = true;
}
...
Any track please? I can't find any signal nor event from the QMainWindow class similar to the Builder's "FormActivate" event. I've read about QEvent::WindowActivate, but I'm not sure this will be good for mi idea.
Thanks again!
Re: About signals and events
why you've override the method event(QEvent). Remove that. Read the documentation--->Reimplemented from QObject::event().
This is the main event handler; it handles event event. You can re implement this function in a subclass, but we recommend using one of the specialized event handlers instead. So, use specialized event handlers.... And where you're emitting the signal FormActivate(). If it is still undefined then dont use it ... comment that..... ALso comment the event method.
Re: About signals and events
all you have to do is overload your showEvent(), or capture it in an event filter.