2016-11-05 16 views
0

"Shadow for qml frameless windows"の重複が可能であることがわかりました。
私は完全に別の最大minと閉じるボタンとドラッグ&ドロップfunctionallityを持つ新しいタイトルバーを作成するしかし、残っている唯一のものは、私のフレームレスウィンドウのカスタムまたはちょうど影です。私はQtとqmlで完全なnewbeです。
さらなるお手伝いをいただきありがとうございます。

カスタムタイトルバーでマイアプリ

enter image description hereqmlのフレームレスウィンドウのカスタムシャドウを作成



は、これはあなたが影にアプリケーションの一部ではなく、より装飾をすることによってそれを行うことができます

import QtQuick 2.0 
import QtQuick.Window 2.0 
import QtQuick.Controls 1.4 
import QtQuick.Controls.Styles 1.4 
//import QtQml 2.2 
Window { 
property int titlebar_wrapper_size:40 
FontLoader { id: segoe_light; source: "fonts/segoe_light" } 
id:registerWindow 
width:800 
height:600 
visible:true 
x:Screen.width/2 - width/2 
y:Screen.height/2 - height/2 
//x: Screen.desktopAvailableWidth/2 - width 
//y: Screen.desktopAvailableHeight/2 - height 

flags: Qt.FramelessWindowHint | 
     Qt.WindowMinimizeButtonHint | 
     Qt.Window 

MouseArea { 
    id:dragparentwindow 
    width: parent.width 
    height: 57 
    property real lastMouseX: 0 
    property real lastMouseY: 0 
    onPressed: { 
     lastMouseX = mouseX 
     lastMouseY = mouseY 
    } 
    onMouseXChanged: registerWindow.x += (mouseX - lastMouseX) 
    onMouseYChanged: registerWindow.y += (mouseY - lastMouseY) 
} 
Rectangle{ 
    id:titlebar 
    width: parent.width 
    Rectangle{ 
     id:appclose 
     height: titlebar_wrapper_size 
     y:0 
     width: titlebar_wrapper_size 
     anchors.right: parent.right 
     Text{ 
      //text: awesome.loaded ? awesome.icons.fa_money : "x" 
      text: "×" 
      anchors.horizontalCenter: parent.horizontalCenter 
      font.pointSize: 20 
     } 
     MouseArea{ 
      width: parent.width 
      height: parent.height 
      hoverEnabled: true 
      onEntered: appclose.color="#ddd" 
      onExited: appclose.color="#fff" 
      onClicked: Qt.quit() 
     } 
    } 
    Rectangle{ 
    id:appminimize 
    height: titlebar_wrapper_size 
    y:0 
    width: titlebar_wrapper_size 
    anchors.right: appclose.left 
    Text{ 
     text: '' 
     font.family: segoe_light.name 
     anchors.horizontalCenter: parent.horizontalCenter 
     font.pointSize: 15 
    } 
    MouseArea{ 
     width: parent.width 
     height: parent.height 
     hoverEnabled: true 
     onEntered: appminimize.color="#ddd" 
     onExited: appminimize.color="#fff" 
     onClicked: registerWindow.visibility = Window.Minimized 
    } 
} 

} 
Text{ 
    text:"XTE" 
    font.family: segoe_light.name 
    font.pointSize: 85 
    anchors.horizontalCenter: parent.horizontalCenter 
    y:70 
} 

TextField{ 
    id:registername 
    style : TextFieldStyle { 
     background:Rectangle{ 
      border.color: "#ccc" 
      radius:17 

     } 
    } 
    width:400 
    height:50 
    y:420 
    font.pointSize: 17 
    font.family: segoe_light.name 
    textColor:"#555" 
    placeholderText: " Enter a nickname ..." 
    anchors.horizontalCenter: parent.horizontalCenter 
    //anchors.verticalCenter: parent.verticalCenter 

} 

Text{ 
    id:login 
    text:"Login" 
    color: "#0084ff" 
    anchors.horizontalCenter: parent.horizontalCenter 
    anchors.top: registername.bottom 
    anchors.topMargin: 17 
    font.family: segoe_light.name 
    font.pointSize: 22 
} 

} 

答えて

1

私のQMLファイルですOSウィンドウマネージャ:

import QtQuick 2.4 
import QtQuick.Window 2.2 
import QtGraphicalEffects 1.0 

Window { 
    id: main 
    visible: true 
    width: 300 
    height: 200 
    color: "#00000000" 
    flags: Qt.FramelessWindowHint | Qt.Window 

    Rectangle { 
     id: rect 
     width: 290 
     height: 190 
     x: 5 
     y: 5 
    } 

    DropShadow { 
     anchors.fill: rect 
     horizontalOffset: 2 
     verticalOffset: 2 
     radius: 5 
     samples: 5 
     source: rect 
     color: "black" 
    } 
} 

enter image description here

+0

はい、このトリックは役に立ちます。 – HosSeinM

関連する問題