Qt-interest Archive, March 2002
AW: determination of active window
Message 1 in thread
I would use 'QWidget* QApplication::activeWindow () const' and then either
query if the returned widget is of your dataForm type using some form of
RTTI (then you would have to make the window index 'i' accessible through
your dataForm class) or hold the QWidget pointers of your dataForm together
with the window index in a std::map (where the QWidget pointer is used as
key) and then using the 'find' method of the map to retrieve the index of
the window.
Tom
-----Ursprüngliche Nachricht-----
Von: Knut C. Naue [mailto:knaue@c8m42.pi.tu-berlin.de]
Gesendet: Dienstag, 05. März 2002 18:30
An: qt-interest@trolltech.com
Betreff: determination of active window
hi all
in my application a loop opens a number of widgets:
dataForm *p[N_DATA];
for (int i=0; i<N_DATA; i++) {
p[i] = new dataForm;
p[i]->show();
};
To apply calculation on a specific set of data i need the number (i) of
the window which is active at the moment of event.
i found some hints in the qt archive using event(QEvent *e) and
eventFilter(QObject *w, QEvent *e).
bool dataForm::eventFilter( QObject *watched, QEvent *e ) // window
activated?
{
bool active;
if (e->type() == QEvent::WindowActivate) // window is activated
active = TRUE;
else
active = FALSE;
return active;
}
so far so good. but how to filter out which window p[i] sent Activate
signal?
any idea? (i found a way in implementing a member function in my data
class which returns the status of each window but this seems not to be
an elegant way.)
thanks in advance.
cu knut
--
[ signature omitted ]