tags:

views:

31

answers:

2

I've override resizeEvent(QResizeEvent * /* SizeEvent */) in a custom widget and I'm wondering if I should call SizeEvent->accept() on the event or just let it pass along.

Since I'm getting it from the parent widget, I'm assuming I can safely accept it, but I haven't been able to find a definitive answer.

Thanks,

A: 

You don't have to. If you do, nothing bad will happen. (Except perhaps your team believing they have to accept resize events.) See a few implementations of resizeEvent() in Qt:

void QWidget::resizeEvent(QResizeEvent * /* event */)
{
}

void QMenuBar::resizeEvent(QResizeEvent *)
{
    Q_D(QMenuBar);
    d->itemsDirty = true;
    d->updateGeometries();
}

void QComboBox::resizeEvent(QResizeEvent *)
{
    Q_D(QComboBox);
    d->updateLineEditGeometry();
}

QResizeEvent::isAccepted is not used in a meaningful way in Qt (as of 4.6.3). As a rule, the documentation of the event class will be explicit when accept() and ignore() have a special meaning. It usually is the case with input events (mouse, key, tablet, touch), notifications that something should be displayed (context menu, help, what is this, tooltip) or that something will hapen, but you can avoid it (close a window).

andref
A: 

if you want the event to end there itself then call accept() or else if you want the event to move to the base class so that let other can use it then call ignore

FYI... http://doc.qt.nokia.com/qq/qq11-events.html

Shadow