Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-29294

Qt::Tool / Qt::Popup flag does not work properly on QQuickView

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 5.0.0
    • Quick: SceneGraph
    • None
    • WinXP

    Description

      The first QQuickView is the father of the second QQuickView, the second view is set a 'Qt::Tool' flag. Then second view should be upon the first view, and the second view should be able to move outsize the area of first view.

      (part)main.cpp
      	QQuickView view;
      	view.setSource(QUrl::fromLocalFile("qml/view.qml"));
      	view.show();
      	
      	QQuickView view2(&view);
      	view2.setFlags(Qt::Tool);
      	view2.rootContext()->setContextProperty("window", &view2);
      	view2.setSource(QUrl::fromLocalFile("qml/view2.qml"));
      	view2.show();
      	qDebug() << view2.winId() << view2.parent()->winId();
      

      But the result is view2 cannot moved outside the area of first view.

      Here are the code of the two qml files:

      qml/view.qml
      import QtQuick 2.0
      
      Rectangle {
      	id: main
          width: 640
          height: 480
      	color: "red"
      }
      
      qml/view2.qml
      import QtQuick 2.0
      
      Rectangle {
      	id: window_rect
      	color: "pink"    
      	width: 240
      	height: 480
      		
      	MouseArea {
      		anchors.fill: parent
      		property variant clickPos
      
      		onPressed: {
      			clickPos  = Qt.point(mouse.x, mouse.y)
      		}
      
      		onPositionChanged: {
      			var delta = Qt.point(mouse.x - clickPos.x, mouse.y - clickPos.y)
      			window.x += delta.x;
      			window.y += delta.y;
      		}
      	}
      }
      

      HOWEVER, when I'm using Qt4, it works properly.

      Qt4Code
              QDeclarativeView *view = new QDeclarativeView();
      	view->setSource(QUrl::fromLocalFile("qml/_view.qml"));
      
      	QDeclarativeView *view2 = new QDeclarativeView(view);
      
      	view2->setWindowFlags(Qt::Tool);
      	view2->rootContext()->setContextProperty("window", view2);
      	view2->setSource(QUrl::fromLocalFile("qml/_view2.qml"));
      
      	view->show();
      	view2->show();
      

      view2 is upon view, and view2 can be moved freely, without the restriction of the first view.

      It just like the behavior of the toolbar of VisualStudio 2010, very common, but now I can't implement it using QQuickView..

      Meanwhile, there are also problems using Qt::Popup. When I set Qt::Popup on a QQuickView, it behaves as if it has no father(top level window). Microsoft Spy++ also proved that it has no father. But I printed it's father using parent():

        qDebug() << view2.winId() << view2.parent()->winId(); 
      

      view2.parent() is not zero.

      I havn't tested these on linux.

      I guess is it related to the new mechanism of QQuickWindow ?

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            sletta Gunnar Sletta
            weiyuemin weiyuemin
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes