查看完整版本: [-- qml,运行时窗口一片黑,控件不显示,求助! --]

QTCN开发网 -> Qt QML开发 -> qml,运行时窗口一片黑,控件不显示,求助! [打印本页] 登录 -> 注册 -> 回复主题 -> 发表主题

eitail 2019-01-23 14:41

qml,运行时窗口一片黑,控件不显示,求助!


代码是网上下载下来的,很简单,应该没有问题,出现如下情况,大神们帮忙看看是什么问题,是我哪里设置的不对,还是其他什么原因?

环境:

Qt Creator 4.7.1
Based on Qt 5.9.7 (Clang 8.0 (Apple), 64 bit)
macOS系统

设计模式里面是这个样子的:
[attachment=19865]

运行之后是这个样子:
[attachment=19864]


具体代码:
  1. import QtQuick 2.3
    import QtQuick.Controls 1.2

    ApplicationWindow {
    visible: true
    width: 400
    height: 210
    color: "#ffffff"
    title: qsTr("QuickControlsDemo")

    Text {
    id: text1
    x: 47
    y: 35
    width: 80
    height: 30
    text: qsTr("用户名:")
    horizontalAlignment: Text.AlignRight
    verticalAlignment: Text.AlignVCenter
    font.pixelSize: 14
    }

    TextField {
    id: textField1
    x: 137
    y: 35
    width: 200
    height: 30
    placeholderText: qsTr("请输入用户名")
    }

    Text {
    id: text2
    x: 47
    y: 85
    width: 80
    height: 30
    text: qsTr("密 码:")
    verticalAlignment: Text.AlignVCenter
    font.pixelSize: 14
    horizontalAlignment: Text.AlignRight
    }

    TextField {
    id: textField2
    x: 137
    y: 85
    width: 200
    height: 30
    echoMode: 2
    placeholderText: qsTr("请输入密码")
    }

    Button {
    id: button1
    x: 71
    y: 145
    width: 116
    height: 36
    text: qsTr("登 录")
    }

    Button {
    id: button2
    x: 224
    y: 145
    width: 110
    height: 36
    text: qsTr("取 消")
    }
    }


eitail 2019-01-23 14:42
[attachment=19867][attachment=19868]

never_forget 2019-01-24 09:30
这个,Window 的前景色被设置了白色;全部都变黑,那就是渲染有问题,你的显卡开启了嘛?支持
OPENGL 不? 要不加个群,帮你看看 ?
点击链接加入群聊【Qt 萌新】:https://jq.qq.com/?_wv=1027&k=5k9qAPb

eitail 2019-01-24 09:40
never_forget:这个,Window 的前景色被设置了白色;全部都变黑,那就是渲染有问题,你的显卡开启了嘛?支持
OPENGL 不? 要不加个群,帮你看看 ?
点击链接加入群聊【Qt 萌新】:https://jq.qq.com/?_wv=1027&k=5k9qAPb
 (2019-01-24 09:30) 

所有的qml程序都是这样,即使是Hello world也是这样的。qwidget的程序正常。

toby520 2019-01-24 10:03
eitail:所有的qml程序都是这样,即使是Hello world也是这样的。qwidget的程序正常。 (2019-01-24 09:40) 

看看你的main.cpp的内容

eitail 2019-01-24 10:50
toby520:
看看你的main.cpp的内容


[attachment=19869]


查看完整版本: [-- qml,运行时窗口一片黑,控件不显示,求助! --] [-- top --]



Powered by phpwind v8.7 Code ©2003-2011 phpwind
Gzip disabled