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:
{
if(event
->type
() == QEvent::Enter) {
if(obj == myQPushButton)
{
myBuPan->move(xloc, yloc);
myBuPan->show();
return QWidget::eventFilter(obj, event
) }
etc...
}
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...
}
To copy to clipboard, switch view to plain text mode
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:
{
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;
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]; }
To copy to clipboard, switch view to plain text mode
Shouldn't this work? ...er, it's not.
...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?
Bookmarks