Qt Graphics Scene mouse event propagation

Posted by Olorin on Stack Overflow See other posts from Stack Overflow or by Olorin
Published on 2010-04-11T17:10:24Z Indexed on 2010/04/11 17:13 UTC
Read the original article Hit count: 361

Filed under:
|
|

hello i'm learning qt and i'm doing the folowing to add some widgets to a graphics scene

void MainWindow::addWidgets(QList<QWidget *> &list, int code)
{
    if(code == CODE_INFO)
    {
        QWidget *layoutWidget = new QWidget();
        QVBoxLayout *layout = new QVBoxLayout();
        foreach(QWidget *w, list)
        {
            layout->addWidget(w);
            this->connect(((ProductInfo*)w), SIGNAL(productClicked()), this, SLOT(getProductDetails()));
        }
        layoutWidget->setLayout(layout);
        this->scene->addWidget(layoutWidget);
    }
}

my ProductInfo class processes mouse release and emits a signal

void ProductInfo::mouseReleaseEvent(QMouseEvent *e)
{
    QWidget::mouseReleaseEvent(e);
    emit productClicked();
}

the problem is after adding the widgets to the scene they no longer get the mouse release event and don't emit productClicked signal but if i add them to the main window(not to the scene) they work as expected. What am i doing wrong?

© Stack Overflow or respective owner

Related posts about c++

Related posts about qt