2017-01-05 7 views
1

私が理解する限り、QtQuickにはドッキング可能なコンテナ用の組み込み機能はありません。私はこれが追加されたいくつかのソースを見つけましたが、どちらの方法を決めるのが難しいですか。QtQuickでのドッキング

https://developer.blackberry.com/native/documentation/dev/custom_components/index.html

How to get a QMainWindow from ApplicationWindow QML file to allow use of QDockWidget with QML files

誰かがQtQuickにドッキングを追加する方法(または好ましくはライブラリ)をお勧めしますか?

+1

当分の間は何もありません、しかし、それは、ハードDIYのではありません。 – dtech

+0

私はこれについてかなり新しいですから、 "それほど難しくない"と思っています。これを実装するにはポインタがありますか?新しいウィンドウを再構築することは、「ドッキング解除」状態を実現するための実現可能な方法ですか? –

+1

はい、あなたはマルチウィンドウのために行きたいなら。また、現在のウィンドウ内にフローティング要素を持つこともできます。 – dtech

答えて

2

ウィジェットをメインウィンドウ(ドッキング状態)から新しいウィンドウ(ドッキング解除状態)に移動する複数のウィンドウで動作する解決策を発見しました。これは、ここで他の人に有用であることを期待して

は完全な例である:

import QtQuick 2.7 
import QtQuick.Controls 2.0 
import QtQuick.Layouts 1.0 
import QtQuick.Window 2.2 

ApplicationWindow { 
    visible: true 
    width: 640 
    height: 480 
    title: qsTr("Hello World") 

    Window { 
     width: 100; 
     height: 100; 
     visible: false; 
     id: wnd 

     Rectangle { 
      id: greenRect 
      anchors.fill: parent 
     } 

     onClosing: { 
      blueRect.state = "docked" 
     } 

    } 

    Item { 
     width: 200; height: 100 

     Rectangle { 
      id: redRect 
      anchors.fill: parent 
     } 

     Rectangle { 
      id: blueRect 
      width: 50; height: 50 
      x: 10; y: 10; 
      color: "blue" 

      states: [ 
       State { 
        name: "undocked" 
        ParentChange { target: blueRect; parent: greenRect; x: 10; y: 10 } 
       }, 
       State { 
        name: "docked" 
        ParentChange { target: blueRect; parent: redRect; x: 10; y: 10 } 
       } 
      ] 

      MouseArea { 
       anchors.fill: parent; 
       onClicked: { 
        blueRect.state = "undocked" 
        wnd.visible = true 
       } 
      } 
     } 
    } 
} 
関連する問題