ウィンドウの内容を表示するために qwidget を qmainwindow に置き換えることができないのはなぜですか?
質問
qwidget から継承したウィンドウ クラスを作成し、別の qwidget で表示できるようにしましたが、ウィンドウ クラスの基本クラスが qmainwidget に変更されると、次の理由により別の qwidget で表示できなくなります。
解決する
QMainWindow と QWidget の場合、1 つのトップレベル ウィンドウのイベントが別のトップレベル ウィンドウで応答するようにするには、2 つのトップレベル ウィンドウをマージする必要があります。たとえば、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: {
}
}
レイアウトは itemAt を横断します
if(m_vlayout->itemAt(0) != nullptr){//有widget在布局里面
qDebug()<<"m_vlayout is not empty-------------------------------------";
QML ウィンドウ ウィンドウ コンポーネントのプロパティ
モダリティ: モーダルかどうか
フラグ:ウィンドウのプロパティ