簡體   English   中英

為什么setMainQmlFile起作用,而setSource對於相同路徑失敗?

[英]Why does setMainQmlFile work and setSource fails for the same path?

為什么setMainQmlFile起作用,而setSource對於相同路徑失敗?

QmlApplicationViewer viewer;
viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);

//viewer.setMainQmlFile(QLatin1String("qml/exQml02/main.qml")); // <-- works
viewer.setSource(QUrl("qrc:qml/exQml02/main.qml")); // <--- fails: qrc:qml/exQml02/main.qml: File not found 

它失敗,因為它不是同一路徑。 第一條路徑是文件系統中的普通路徑。 那里您的main.qml存在。 第二個是Qt資源系統中的路徑。 嘗試將main.qml嵌入二進制文件時,您似乎犯了一個錯誤。 您是否嘗試嵌入main.qml?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM