标签: qt-quick

QML 中 Flickable.contentY 的边界

询问 Flickable.contentY 边界的正确方法是什么?我需要滚动条。

通过实验我发现

offsetY <= contentY <= offsetY + contentHeight - height
Run Code Online (Sandbox Code Playgroud)

其中 offsetY 可以计算为

var offsetY = contentY-Math.round(visibleArea.yPosition*contentHeight)
Run Code Online (Sandbox Code Playgroud)

offsetY 在应用程序开始时为零,除非调整 Flickable 的大小,否则它似乎是恒定的。

这个公式一般有效,但可能应该有一个专门的函数。

qml qt-quick flickable

0
推荐指数
1
解决办法
3983
查看次数

滚动条不显示在 Qt Quick ScrollView 中

我有两个ColumnLayout,我希望它们可以滚动,但是滚动条不显示。如果我删除一列,它就会显示出来。

代码:

ApplicationWindow {
    id: applicationWindow1
    visible: true
    width: 400
    height: 500
    title: qsTr("Hello World")

    menuBar: MenuBar {
        Menu {
            title: qsTr("File")
            MenuItem {
                text: qsTr("Exit")
                onTriggered: Qt.quit();
            }
        }
    }

    Item {
        id : scroll;
        anchors.centerIn: parent
    }

    ScrollView {
        anchors.left: parent.left
        anchors.top : parent.top
        id:col1
        width: 240
        height: 618
        anchors.leftMargin: 0
        anchors.topMargin: 0
        contentItem : fl0
        frameVisible :true

        ColumnLayout  {
            id:fl0

            anchors.fill:parent


           Rectangle{
               width:200
               height:200
               color : "#585ef3"
           }
           Rectangle{
               width:200
               height:200
               color : "#585ef3"
           } …
Run Code Online (Sandbox Code Playgroud)

qt qml qt-quick

0
推荐指数
1
解决办法
2228
查看次数

将子项嵌入自定义类型的子项中

我正在 QML 中创建一个自定义类型,其Column内部有一个GroupBox. 当该类型的用户向其中添加组件时CustomType,它们应该位于Column,而不是GroupBox。如何在不制作额外包装文件的情况下实现这一点?

//CustomType.qml

GroupBox {
    Column {

    }
}


//Main.qml

CustomType {
    CheckBox {//This should be inside the Column of the GroupBox in CustomType   
    }
}
Run Code Online (Sandbox Code Playgroud)

qt qml qt-quick qtquick2

0
推荐指数
1
解决办法
222
查看次数

Qt快速控制ListView大小问题

我使用Qt Quick Controls 2时出现弹出窗口大小行为的问题.当我将ListView作为弹出窗口的contentItem时,弹出窗口大小为零.一些重现问题的示例代码:

import QtQuick 2.4
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3

ApplicationWindow {
    id: window
    visible: true
    width: 800
    height: 600

    Button {
        text: "open popup"
        onClicked: popup.open()
    }

    Popup {
        id: popup
        x: (window.width - width) / 2
        y: window.height / 6
        width: contentWidth
        height: contentHeight

        contentItem: ListView {
            width: contentWidth
            height: contentHeight
            model: ListModel {
                ListElement {
                    name: "Apple"
                    cost: 2.45
                }
                ListElement {
                    name: "Orange"
                    cost: 3.25
                }
                ListElement {
                    name: "Banana"
                    cost: 1.95
                } …
Run Code Online (Sandbox Code Playgroud)

qt qml qt-quick qtquick2 qtquickcontrols2

0
推荐指数
1
解决办法
1031
查看次数

QtQml和QtQuick有什么区别?

http://doc.qt.io/qt-5/qtqml-qmlmodule.html

QtQml和QtQuick似乎是不同的东西,这就是为什么有两个单独的import语句.

import QtQml 2.2
import QtQuick 2.3

QtQml和QtQuick之间有什么区别,在哪些现实案例中应该使用它们?

qt qml qt-quick qtquick2

-1
推荐指数
1
解决办法
291
查看次数

标签 统计

qml ×5

qt-quick ×5

qt ×4

qtquick2 ×3

flickable ×1

qtquickcontrols2 ×1