qml进度条

为什么qwidget换成qmainwindow就不能显示窗口内容了

问题

写了一个窗口类继承自qwidget,放在另一个qwidget中可以显示,将该窗口类的基类改成qmainwidget就无法在另一个qwidget中显示,是因为:

解决

QMainWindow和QWidget,想让一个顶级窗口中的事件能够在另外一个顶级窗口中响应,必须把两个顶级窗口合并,比如setCentralWidget就可以把Qwidget设置为QMainWindow的主窗口

参考自:setCentralWidget就可以把Qwidget设置为QMainWindow的主窗口 - findumars - 博客园

添加网络映射位置

qml进度条显示

import QtQuick.Controls 1.4 
import QtQuick.Controls.Styles 1.4
Slider{
            id:sliderRectangle
            minimumValue: 0
            maximumValue: 100
            value: 20
            wheelEnabled : false
            anchors.left: parent.left
            anchors.leftMargin: 87
            anchors.right: parent.right
            anchors.rightMargin: 39
            anchors.verticalCenter: parent.verticalCenter
            height: 40
            style: SliderStyle
            {
                handle: Rectangle//手柄
                {
                    anchors.centerIn: parent;
                    color: "yourcolor"
                    border.color: "yourcolor"
                    border.width: 1
                    width: 10
                    height: 10
                    radius: 5
                }
                groove: Rectangle {//滑槽
                    implicitHeight: 2
                    color: "yourcolor"
                    radius: 1
                    Rectangle {
                        implicitHeight: 2
                        color: "yourcolor"
                        implicitWidth: styleData.handlePosition
                        radius: 1
                    }
                }
            }
            onValueChanged: {

            }
        }

layout遍历itemAt

            if(m_vlayout->itemAt(0) != nullptr){//有widget在布局里面
            qDebug()<<"m_vlayout is not empty-------------------------------------";

QML窗口window组件属性

modality: 是否模态



flags: 窗口属性

猜你喜欢

转载自blog.csdn.net/caicai_xiaobai/article/details/117692159