Qt-interest Archive, March 2002
determination of active window
Message 1 in thread
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
Message 2 in thread
I've created QString qs[2][2] array and initialized it with :
QString qs[2][2] = {{"one", two"}, {"three", four"));
Everything works fine and I can access all 4 QStrings,
but if I change it to:
const QString qs[2][2] = {{"one", two"}, {"three", four"));
the 2 values disapper! I get the results: "one one three three".
The same code works fine with char*, const char*, QString* or const
QString*. Is it compiler bug (RH7.2 + gcc-2.96-88) or Qt? Anyone else
has the same problem?
gr,
Tomasz Bury
Message 3 in thread
Why don't you use "QWidget *QApplication::activeWindow()" ?!
You than have to compare the address of the returned QWidget to p[i] and if
they are equal, return i...
Hope this helps,
Rene
--
[ signature omitted ]