• 5216阅读
  • 5回复

qml怎么去掉最大化按钮 [复制链接]

上一主题 下一主题
离线dcx013
 

只看楼主 倒序阅读 楼主  发表于: 2016-07-11
qml怎么去掉最大化按钮,像360那样,qt5.7
离线咬蚊嚼渍

只看该作者 1楼 发表于: 2016-07-11
在qml根视图,就是ApplicaptionWindow或Window里添加
flags: Qt.Window | Qt.FramelessWindowHint ;
就可以了。
然后自定义最大化最小化什么的这些按钮
离线cycloveu

只看该作者 2楼 发表于: 2016-08-10
用QQuickView 可以实现 自定义标题栏+窗口阴影。 QQmlEngine+flags 可以自定义标题栏 但窗口阴影不能实现。
大道至简 悟在天成
离线cuisy

只看该作者 3楼 发表于: 2017-07-01
    Rectangle {
        id: titleRect;
        color: "#00A600";
        anchors.top: parent.top;
        anchors.left: parent.left;
        anchors.right: parent.right;
        height: 25;

        TitleButton {   //关闭按钮
            id: closeButtonDialog;
            width: 20;
            height: 18;
            anchors.right: parent.right;
            anchors.verticalCenter: parent.verticalCenter;
            anchors.rightMargin: 2;

            normalPath: "qrc:/Image/Close2.png";
            enterPath: "qrc:/Image/Close3.png";
            pressPath: "qrc:/Image/Close1.png";

            onButtonClick: usrMngWnd.destroy();
        }

        Rectangle {
            id: dragDialog;
            anchors.top: titleRect.top;
            anchors.left: titleRect.left;
            anchors.right: closeButtonDialog.left;
            anchors.bottom: titleRect.bottom;
            color: "darkBlue";

            MouseArea {
                anchors.fill: dragDialog;
                acceptedButtons: Qt.LeftButton;
                property point clickPos: "0,0";
                onPressed: {
                    clickPos  = Qt.point(mouse.x,mouse.y);
                }

                onPositionChanged: {
                    //鼠标偏移量
                    var delta = Qt.point(mouse.x-clickPos.x, mouse.y-clickPos.y);

                    //如果mainwindow继承自QWidget,用setPos
                    self.setX(self.x+delta.x);
                    self.setY(self.y+delta.y);
                }
            }

            Label {
                id: titleWindowLabel;
                anchors.horizontalCenter: parent.horizontalCenter;
                anchors.verticalCenter: parent.verticalCenter;
                color: "#fffffb";
                text: qsTr("标题");
                font.bold: true;
            }
        }
    }
离线spark253649

只看该作者 4楼 发表于: 2017-07-01
窗口阴影的话你主窗口透明里面的窗口比如rectangle加一个效果,可以参考Graphical Effects
业精于勤荒于嬉!
离线dd759378563

只看该作者 5楼 发表于: 2017-08-02
设置Flag为Qt::CustomizeWindowHint
如果你main.cpp里面用的是QQmlEngine,就在qml的根部ApplicationWindows里面写flags: Qt.Customi
zeWindowHint,
如果是用的QQuickView,就在main.cpp里面view.setFlags(Qt::CustomizeWindowHint);
涛哥是个Qml高手,著有《Qml组件化编程》《Qml特效》系列教程,见知乎专栏-Qt进阶之路:https://zhuanlan.zhihu.com/TaoQt
或微信公众号:Qt进阶之路
快速回复
限100 字节
 
上一个 下一个