Adding GLWidgets at runtime



  • Hi All,

    I have three GLWidgets, and I would like to show two of them into that third GLWidget on mouse press.. I tried to add widget on mousepress for each widget, but I can't get copy of the widget that is pressed. The whole widgets gets added to the layout, and it is cleared from its on layout!

    I use the following code
    @bool QMainWindow::eventFilter(QObject *target, QEvent *event)
    {
    if (target == m_pThersholdedGLWidget || target == m_pInputGLWidget) {
    if (event->type() == QEvent::MouseButtonPress)
    {
    QGLWidget pWidget = dynamic_cast<QGLWidget>(target);

    QGLWidget *pNewWidget = new QGLWidget(this);

    if(pWidget)
    {
     QLayoutItem* item;
     while ( ( item = ui.sourcehorizontalLayout->layout()->takeAt( 0 ) ) != NULL )
     {
      delete item->widget();
      delete item;
     }
     //delete ui.sourcehorizontalLayout->layout();
    
     ui.sourcehorizontalLayout->addWidget(pWidget);
     pWidget->show();
     this->show();
    
    
    }
    std::cout<<"clicked on"<<pWidget<<std::endl;
    return true;
    

    }
    }

    return QMainWindow::eventFilter(target, event);
    }@



  • Is there any idea guys ?



  • [quote author="AndreAhmed" date="1341314891"]Is there any idea guys ?[/quote]

    Don't "kick" your topics, especially this fast. Allow at least two days, but idealy up to a week for people to answer.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.