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. [PARTLY SOLVED]-Toolbars don't stay on top of the main window when floated
QtWS25 Last Chance

[PARTLY SOLVED]-Toolbars don't stay on top of the main window when floated

Scheduled Pinned Locked Moved General and Desktop
8 Posts 2 Posters 2.9k Views
  • 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.
  • K Offline
    K Offline
    kenchan
    wrote on last edited by
    #1

    Hello,

    I have made a simple MainWindow application that uses a QMdiArea and QGLWidget inside a QGraphicsView as a sub window. There is also a floatable toolbar docked at the top of the MainWindow.

    My problem is that the toolbar will not stay above the MainWindow when it is floated. As far as I can see this only happens when I use the QGraphicsView/QGLWidget combination as a subwindow. The toolbars will float on top of the main window when other types such as a QTextEdit are used.

    It would be nice if the toolbars would float normally... does anyone have any ideas as to why this is happening and how I can fix it?

    I am sure I must be doing something wrong so here is some simple code.

    @
    ...
    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent)
    {

    // add a MdiArea Widget
    QMdiArea *mdi = new QMdiArea();
    setCentralWidget(mdi);
    
    // add a gl subwindow
    QGraphicsView *sceneView = new QGraphicsView();
    mdi->addSubWindow(sceneView);
    QGraphicsScene *scene = new QGraphicsScene();
    sceneView->setScene(scene);
    sceneView->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
    
    // add a QToolBar and a text button
    QToolBar *tb1 = new QToolBar(this);
    tb1->setAllowedAreas(Qt::AllToolBarAreas);
    QToolButton *btn = new QToolButton();
    btn->setText("[Click Me]");
    tb1->addWidget(btn);
    addToolBar(tb1);
    
    // draw some stuff
    QPen pen(Qt::black);
    pen.setWidth(3);
    qreal pos=0.0,inc=10.0;
    for(long i=0; i<10000; i+=10)
    {
        scene->addLine(0.0,pos,10000.0,pos,pen);
        scene->addLine(pos,0.0,pos,10000.0,pen);
        pos += inc;
    }
    

    }
    ...
    @

    Many thanks.

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kenchan
      wrote on last edited by
      #2

      OK Folks,

      I am seeing this issue on Qt 5.0.2 on Windows 7 and Mac OS X 10.8.4. It only happens when a QGLWidget is used as the sub window in the QMdiArea.

      The effect on the Mac is really bad tool bars don't dock again after they are floated, strange things happen to the sub windows when they are dragged. Qt will crash if I fiddle with the tool bars too much.

      Is this a known issue, has anyone seen anything like this. I did not notice anything like this in the known issues docs?

      My thanks to anyone with suggestions.

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

        Hi,

        You should try with the latest Qt (5.1 has just been released). If you are still experiencing this, fill a bug report with a little sample program and as much details you can give. That's the better way to have it handled.

        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
        • K Offline
          K Offline
          kenchan
          wrote on last edited by
          #4

          Thank you,

          I will try it on Qt 5.1 and see what happens. I will submit a bug report if i see the same issues.

          1 Reply Last reply
          0
          • K Offline
            K Offline
            kenchan
            wrote on last edited by
            #5

            Update on this issue.
            I tried it with Qt 5.1.0 and saw no appreciable difference on either Windows 7 or Mac OS X. I will send in a bug report and see what advice the developers can offer me.

            Thanks.

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

              Don't forget to post here the bug link, so others may see it

              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
              • K Offline
                K Offline
                kenchan
                wrote on last edited by
                #7

                OK will do.

                1 Reply Last reply
                0
                • K Offline
                  K Offline
                  kenchan
                  wrote on last edited by
                  #8

                  Hello again,

                  This issue is half resolved for me. The floating tool bar issue can be fixed by using an attribute on your application object like this:

                  @
                  app.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
                  @

                  This works for Windows and Mac OS X.

                  Regarding the other part of my issue. Problems with QGLWidgets used in a QMdiArea this is a known issue and my visit to the bug reporting site revealed this previous bug report awaiting some more action.

                  "<QTBUG-26162>":https://bugreports.qt-project.org/browse/QTBUG-26162

                  Anyone who is interested in using Open GL in a QMainWindow with a QMdiArea as the central widget (i.e. an MDI type GUI scenario) on the Mac platform please go the link above and vote! vote! vote! and hopefully the priority will be escalated and it will be fixed soon :-).

                  In the meantime a workaround is to not use a QMdiArea as a central widget in a QMainWindow when using Open GL but use a QTabWidget or a QSplitter or both if you want multiple widows with a splitter bar. I much prefer an MDI type scenario but this workaround works with GL Widgets on the Mac. You can see some visible flashing of backplane garbage when you size the windows but that is part of the bug mentioned above so it might get fixed too.

                  I hope this helps anyone else who hits the same issue.

                  Again... any Mac users out there, pleeeeese go and vote for that bug.

                  Thanks.

                  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