标题:qml,运行时窗口一片黑,控件不显示,求助!
作者:eitail
日期:2019-01-23 14:41
内容:
代码是网上下载下来的,很简单,应该没有问题,出现如下情况,大神们帮忙看看是什么问题,是我哪里设置的不对,还是其他什么原因?
环境:
Qt Creator 4.7.1
Based on Qt 5.9.7 (Clang 8.0 (Apple), 64 bit)
macOS系统
设计模式里面是这个样子的:
运行之后是这个样子:
具体代码:
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("取 消")
}
}
#1 [eitail 01-23 14:42]
#2 [never_forget 01-24 09:30]
这个,Window 的前景色被设置了白色;全部都变黑,那就是渲染有问题,你的显卡开启了嘛?支持
OPENGL 不? 要不加个群,帮你看看 ?
点击链接加入群聊【Qt 萌新】:https://jq.qq.com/?_wv=1027&k=5k9qAPb
#3 回 never_forget 的帖子 [eitail 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的程序正常。
#4 回 eitail 的帖子 [toby520 01-24 10:03]
eitail:所有的qml程序都是这样,即使是Hello world也是这样的。qwidget的程序正常。 (2019-01-24 09:40)
看看你的main.cpp的内容
#5 Re:回 eitail 的帖子 [eitail 01-24 10:50]
toby520:
看看你的main.cpp的内容