vonCZ
9th December 2007, 12:40
I've subclassed QWidget to make a button panel: BuPan. BuPan consists of buttons, a slider, and checkBoxes: it's a small panel that pops up next to a QPushButton in my mainApplication like so:
bool Window:eventFilter(QObject *obj, QEvent *event)
{
if(event->type() == QEvent::Enter)
{
if(obj == myQPushButton)
{
myBuPan->move(xloc, yloc);
myBuPan->show();
return QWidget::eventFilter(obj, event)
}
etc...
}
pb[0] is a button in myBuPan. I want to check for an Enter event on this particular button within BuPan; I thought I could do the following:
bool Window:eventFilter(QObject *obj, QEvent *event)
{
if(event->type() == QEvent::Enter)
{
if(obj == myQPushButton)
{
myBuPan->move(xloc, yloc);
myBuPan->show();
return QWidget::eventFilter(obj, event);
}
if(obj == myBuPan->get_pb(0))
{
qDebug("HIT!!");
return QWidget::eventFilter(obj, event);
}
etc...
// ...and I have the following in bupan.h:
QList<QPushButton *> pb;
QPushButton *get_pb(int value) { return pb[value]; }
Shouldn't this work? ...er, it's not.:o ...ideas?
Or will I have to add an "enterEvent(QEvent *event)" method to the BuPan class itself? If I have to do this second option: How can I write the bupan "enterEvent" method so that it's generic... for example, so that pb[0] and pb[2] will capture enterEvents on one instance of BuPan, but on another instance only pb[4] might capture the events?
bool Window:eventFilter(QObject *obj, QEvent *event)
{
if(event->type() == QEvent::Enter)
{
if(obj == myQPushButton)
{
myBuPan->move(xloc, yloc);
myBuPan->show();
return QWidget::eventFilter(obj, event)
}
etc...
}
pb[0] is a button in myBuPan. I want to check for an Enter event on this particular button within BuPan; I thought I could do the following:
bool Window:eventFilter(QObject *obj, QEvent *event)
{
if(event->type() == QEvent::Enter)
{
if(obj == myQPushButton)
{
myBuPan->move(xloc, yloc);
myBuPan->show();
return QWidget::eventFilter(obj, event);
}
if(obj == myBuPan->get_pb(0))
{
qDebug("HIT!!");
return QWidget::eventFilter(obj, event);
}
etc...
// ...and I have the following in bupan.h:
QList<QPushButton *> pb;
QPushButton *get_pb(int value) { return pb[value]; }
Shouldn't this work? ...er, it's not.:o ...ideas?
Or will I have to add an "enterEvent(QEvent *event)" method to the BuPan class itself? If I have to do this second option: How can I write the bupan "enterEvent" method so that it's generic... for example, so that pb[0] and pb[2] will capture enterEvents on one instance of BuPan, but on another instance only pb[4] might capture the events?