Qt 스를 넣어 요소가 위에서 서랍

0

질문

나는 어려움을 겪고 매우 기본적인 질문..

QT5.15.2:

우리는 간단한 응용 프로그램 중 하나는 기본 창 및 2-3sub-창(1 수준에서 아래로 주요). 주요 창로 구성되어 있는 내용의 항목,헤더와 몇몇 메뉴 플랩에 분산됩니다. 그래서 멀리 하위 페이지 열리 서랍 요소입니다.

그러나 드로 오버레이는 날개와 헤더에 한 번 열리고 우리는 다시 instanciate 플랩과 헤더에서 서랍을 볼 수 있습니다. 이것은 정말 좋습니다. 하는 방법은 없을 정의합 z 레벨에서는 서랍을 열? (설정을 분명히 z 작동하지 않).


Item{
  id: id_mainWindow
  z: 0
  Drawer{
    id: id_subMenu1
    anchors.fill: parent
    z: 1
    
    /* Not so nice workaround */
    Button{
      id: id_subClose
      z: 100
      onClicked{
        id_subMenu1.close()
      }
    }
  }

  /* Unfortunately, this one gets hidden once, the drawer is open */
  Button{
    id: id_subOpenClose
    z: 100
    onClicked{
      if( id_subMenu1.open ){
        id_subMenu1.close()
      } else {
        id_subMenu1.open()
      }
    }
  }

}
qml qt qt5.15
2021-11-19 07:31:58
1

최고의 응답

0

나는 것이 좋습니다 Drawer 하지 않은 구성 요소에 대한 이 일로 그것은 기술적으로 Popup. 그것은 체크 아웃 가치가있을 수도 있습니 TabBar 구성 요소를 대신 합니다.

그럼에도 불구하고 여기에 다시 쓰기 코드는 Drawer 열을 포함하지 않고 당신 id_subOpenClose 단추입니다.

import QtQuick
import QtQuick.Controls
import QtQuick.Controls.Material

Rectangle {
    id: id_mainWindow
  
    anchors.fill: parent
  
    Drawer {
        id: id_subMenu1
    
        /*
        Set the Drawer's height and y position so that it does not cover your button
        */
        y: id_subOpenClose.height
        height: id_mainWindow.height - id_subOpenClose.height
        width: id_mainWindow.width

        // Do not dim background
        dim: false
        
        // Set this to zero if you want no shadow
        Material.elevation: 2
    
        edge: Qt.RightEdge
    
        Label {
            text: 'Hello World'
            anchors.centerIn: parent
        }
    }

    /* 
    This is your header button that was getting hidden
    Here it stays as if it were part of a global header and does not get hidden by
    the Drawer.
    */
    Button{
        id: id_subOpenClose
        text: id_subMenu1.visible? 'close': 'open'
        onClicked: id_subMenu1.visible? id_subMenu1.close(): id_subMenu1.open()
    }
}

대화형 WASM 를 들어 위의 참 여기에.

2021-12-01 15:56:39

다른 언어로

이 페이지는 다른 언어로되어 있습니다

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................