的的TextInput元素文本:QML:不能看到我已創建QML/test.qml文件QML
import QtQuick 1.0
Rectangle
{
id: pahe
width: 200; height: 50
color: "#55aaee"
TextInput
{
id: editor
anchors
{
left: parent.left; right: parent.right; leftMargin: 10; rightMargin: 10
verticalCenter: parent.verticalCenter
}
cursorVisible: true;
font.bold: true
color: "#151515";
selectionColor: "Green"
focus: true
}
}
和一個QML/main.cpp的文件爲:
#include <QApplication>
#include <QtDeclarative>
#include <QDeclarativeView>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QDeclarativeView view;
view.setSource(QUrl::fromLocalFile("test.qml"));
view.setResizeMode(QDeclarativeView::SizeRootObjectToView);
view.show();
return app.exec();
}
我使用類似這樣的命令編譯這個main.cpp中的文件:
#qmake -project
#qmake
#make
和我運行的EXE爲:
./qml
所以問題在於,即使在使用鍵盤輸入文本後,我也無法在TextInput上看到任何文本。如果我打印元素的TextInput.text,它會在控制檯日誌中顯示輸入的文本,但無法在屏幕上看到。 可能是什麼原因?
如果我使用qmlviewer運行相同的test.qml文件,它工作正常。
任何提示或評論在這將是有幫助的。
感謝,
KBalar
我在Linux上運行它。我嘗試了不同的背景和不同的字體顏色。但我仍然有一個問題。 – kbalar
嘗試運行來自Qt Creator本身。就像使用Qt Simulator或通過定位桌面一樣。 – RajaRaviVarma