• 3339阅读
  • 5回复

qml,运行时窗口一片黑,控件不显示,求助! [复制链接]

上一主题 下一主题
离线eitail
 

只看楼主 倒序阅读 楼主  发表于: 2019-01-23
回复本帖可获得5RMB金钱奖励!
每人最多可获奖1次,奖池剩余0RMB金钱 (中奖几率50%)

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

环境:

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
  2. import QtQuick.Controls 1.2
  3. ApplicationWindow {
  4. visible: true
  5. width: 400
  6. height: 210
  7. color: "#ffffff"
  8. title: qsTr("QuickControlsDemo")
  9. Text {
  10. id: text1
  11. x: 47
  12. y: 35
  13. width: 80
  14. height: 30
  15. text: qsTr("用户名:")
  16. horizontalAlignment: Text.AlignRight
  17. verticalAlignment: Text.AlignVCenter
  18. font.pixelSize: 14
  19. }
  20. TextField {
  21. id: textField1
  22. x: 137
  23. y: 35
  24. width: 200
  25. height: 30
  26. placeholderText: qsTr("请输入用户名")
  27. }
  28. Text {
  29. id: text2
  30. x: 47
  31. y: 85
  32. width: 80
  33. height: 30
  34. text: qsTr("密 码:")
  35. verticalAlignment: Text.AlignVCenter
  36. font.pixelSize: 14
  37. horizontalAlignment: Text.AlignRight
  38. }
  39. TextField {
  40. id: textField2
  41. x: 137
  42. y: 85
  43. width: 200
  44. height: 30
  45. echoMode: 2
  46. placeholderText: qsTr("请输入密码")
  47. }
  48. Button {
  49. id: button1
  50. x: 71
  51. y: 145
  52. width: 116
  53. height: 36
  54. text: qsTr("登 录")
  55. }
  56. Button {
  57. id: button2
  58. x: 224
  59. y: 145
  60. width: 110
  61. height: 36
  62. text: qsTr("取 消")
  63. }
  64. }

离线eitail

只看该作者 1楼 发表于: 2019-01-23
离线never_forget

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

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

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

只看该作者 4楼 发表于: 2019-01-24
回 eitail 的帖子
回帖奖励+ 5
eitail:所有的qml程序都是这样,即使是Hello world也是这样的。qwidget的程序正常。 (2019-01-24 09:40) 

看看你的main.cpp的内容
QtQML多多指教开发社区 http://qtclub.heilqt.com
将QtCoding进行到底
关注移动互联网,关注金融
开发跨平台客户端,服务于金融行业
专业定制界面
群号:312125701   373955953(qml控件定做)
离线eitail

只看该作者 5楼 发表于: 2019-01-24
Re:回 eitail 的帖子
toby520:
看看你的main.cpp的内容



快速回复
限100 字节
 
上一个 下一个