Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Adding GLWidgets at runtime
Qt 6.11 is out! See what's new in the release blog

Adding GLWidgets at runtime

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AndreAhmed
    wrote on last edited by
    #1

    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);
    }@

    1 Reply Last reply
    0
    • A Offline
      A Offline
      AndreAhmed
      wrote on last edited by
      #2

      Is there any idea guys ?

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #3

        [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.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved