qml progress bar

Why can't qwidget be replaced by qmainwindow to display the window content?

question

I wrote a window class inherited from qwidget, which can be displayed in another qwidget. If the base class of the window class is changed to qmainwidget, it cannot be displayed in another qwidget because:

solve

QMainWindow and QWidget, if you want events in one top-level window to respond in another top-level window, you must merge the two top-level windows. For example, setCentralWidget can set Qwidget as the main window of QMainWindow

Reference from: setCentralWidget can set Qwidget as the main window of QMainWindow - findumars - 博客园

Add a network map location

qml progress bar display

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 traverses itemAt

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

QML window window component properties

modality: whether it is modal



flags: window properties

Guess you like

Origin blog.csdn.net/caicai_xiaobai/article/details/117692159