4Manuals

  • PDF Cloud HOME

将我自己的QML按钮插入GridLayout Download

    Android 10,API29:在应用程序文件夹中使用C ++库编写文件会使应用程序崩溃 如何用NSight的Qt5调试OpenGL程序? 将tensorflow lite与Qt一起使用 用于OpenGL调试模式的QWindow :: setFormat可以运行,但是核心模式被忽略 如何在Qt中实现SQL数据库? 如何在Windows上为python 3.7配置pyqt4? QML:如何将滚动条添加到ListView 如何在单击按钮时切换SVG图标-使用QT C ++ Qt-为什么我在qml资源中添加10Mb文件后Visual Studio 2019不再能够编译我的项目? 如何子类化QString

我是Qt的新手,并且想要在GridLayout中使用一些Button(在带有Rectangle的单独.qml文件中制成)。不幸的是,似乎没有将Button定位到不同的单元格。一切都在第一行/列中。是否有必要为ID提供变量,例如数组?还是QML动态对象? 这里的按钮:

Item {
property string textOnButton: "Test"
property int w: 130
property int h: 100

Rectangle{
    id: emptyRectangle
    width: parent.w
    height: parent.h
    Text {
        text: parent.parent.textOnButton + parent.index
        anchors.horizontalCenter: parent.parent.horizontalCenter
        topPadding: 6
        font.pixelSize: 30
    }
 }

}

这里是几次放置Item的GridLayout:

GridLayout{
    id:grid1
    rows: 3
    Layout.margins: 20
    anchors.horizontalCenter: parent.horizontalCenter
    anchors.verticalCenter: parent.verticalCenter
    columnSpacing: 10
    rowSpacing: 10
    EmptyButton{
        id: eins
        textOnButton: "HELP"
    }
    EmptyButton{
        id: zwei
        textOnButton: "HELP"
    }

}

稍后,我想在按钮上使用不同的颜色/文字并例如切换不同的灯。 谢谢您的帮助!

0 个答案:

没有答案



Similar searches
    从DER ApplicationSpecific对象获取可读数据 如何在ListView WPF VB.net中实现延迟加载 Windows 10是否有以Linux为主题的开始菜单? 为什么此延迟语句在一种情况下会影响结果,而在另一种情况下却不影响结果? 浮动零时将y轴隐藏在某个x值以下