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. Dynamic Qframe

Dynamic Qframe

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.2k 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.
  • S Offline
    S Offline
    saghi.sharif
    wrote on last edited by
    #1

    Hi,

    In my application I have a openGL window that I have added to a QGridLayout as a widget and this QGridLayout is set as a layout for a QFrame. On run-time I need to remove this OpenGL window from the QFrame and show it separately from main window by right clicking on it. and the reveres ; I need to add it back to the QFrame as a widget of a QGridLayout.

    this is just a part of test code to see if I can add the OpenGL widget to the layout and remove it afterwards and show it on a separate window:

    @
    QFrame* m_editFrame;
    QGridLayout* layout = new QGridLayout;

    .
    .
    .
    m_canvas = new CanvasRender(0, layout); // OpenGL context

    layout->addWidget(m_canvas, 6, 1);
    //layout->removeWidget(m_canvas);

    m_editFrame->setLayout(layout);
    layout->removeWidget(m_canvas);

    m_editFrame-> setLayout(layout);
    m_editFrame->installEventFilter(this);

    initialize();
    m_canvas->show();
    @

    if I call this line @layout->removeWidget(m_canvas); @ exactly after adding the widget to layout then it works fine. otherwise the openGL window (which is inherited from QGLWidget) is separated from layout but not the Qframe and it sticks to the frame and you can't move it around. I have search a lot but couldn't find a solution. I will be glad for any help! :)

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      If I'm not mistaken, your CanvasRender is still parented to your QFrame, set it's parent to 0 after removing it and you should be able to move it around.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • S Offline
        S Offline
        saghi.sharif
        wrote on last edited by
        #3

        hi,

        Thanks! yeah that was the problem and now it's fixed!

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          You're welcome,

          Since it's all good, don't forget to update the thread's title to solved so other forum users may know a solution has been found :)

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          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