Solved Problems in practicing and running an example
-
@tomy
Hi
I would move the images to an image folder under the project.
Then i would use a qres file and the ":/" syntax
(like here engine.load(QUrl(QLatin1String("qrc:/main.qml")));)https://www.youtube.com/watch?v=sWIQIi4lg58
http://www.bogotobogo.com/Qt/Qt5_Resource_Files.phpYou can right click an image when inside the qres file and get path there.
-
Hi,
The purpose is to add a folder (or some files) to the project as resources to use them easier, yeah? OK, I did these:
According to the tuts, I created a Resource file named MyRes like this.
Please note that the Path there is the same path as the project (Main).I use /MyFiles as the Prefix and add all 4 files, the images (from the image folder on the Desktop).
When adding the files, this message is appeared for all four files. I don't know what to do here. -
@tomy
Hi
Can you right click myres.qrc and choose "Add existing files" , then
select the images. ? -
Yes,
And it resulted in this!
-
That is why i wanted you to move the images to under the project.
The :/Myfile path is not correct. the files are not there...Anyway, now right click each image and you can copy correct path to use.
-
The program runs without error but show nothing! Does it work for you please?
What is the problem of this part if it's correct?You say that you would move the images to an image folder under the project. But how? If you mean using those two tuts, I tried and also posted the error I faced at that time. The current style of adding the path of images (as shown in the screenshot) is rather ugly I think moving the images into a folder under the project would be nicer and better.
-
@tomy
Just use the normal explorer to move the files under the project
Try to use the qrc:/ syntax then. Since its compiled into the
.exe i assumed :/ would work. -
Just use the normal explorer to move the files under the project
What is this please?
This time I tried the following but no success again.
I copied the images folder into the project folder and used an images.qrc file like this and ran the app using that prefix name. It says it cannot open the files! What is the problem this time?
Where did I go wrong? -
Tried again using a new project named
Main3
as below, copying theimage
folder into the project folder.
Here is the content of the files:
main3.pro
main.cpp
images.qrc
main.qml
page1.qml
Page1Form.ui.qml
qtquickcontrols2.confThe program runs:
Issues
window shows nothing.
Application Output
shows this:
Starting C:\Users\Abbasi\Documents\QML\Main3\Main3\build-Main3-Desktop_Qt_5_9_0_MinGW_32bit-Debug\debug\Main3.exe...
QML debugging is enabled. Only use this in a safe environment.Compile Output
shows:
12:35:55: Elapsed time: 00:00.And
General Messages
shows nothing.The app shows nothing as the output.
What is the problem? Why can't I run this example successfully?
Why everything with Qt is that complicated and confusing? -
@tomy
You are still having issues with the paths/syntax
The path you use is invalid
Should have the form
qrc:/images/filename.pngUse the right click menu to make sure its correct.
-
I used, no changes in result! :(
-
@tomy
Then I dont know.
Where did you get sample from ? -
From here, Digesting an User Interface.
-
@tomy
I made a default QML projected
added image folder in project folder and used
Image {
id: root
source: "qrc:/images/test.png"
}and it loaded image.
So what ever goes wrong in your project, its minor.
-
I made a default QML projected
Is it different from the "Qt Quick Console 2 Application" project? You yourself told me to create such a project above.
added image folder in project folder and used
Image {
id: root
source: "qrc:/images/test.png"
}and it loaded image.
So what ever goes wrong in your project, its minor.
Do you do the works just like me? And do your files contain the same thing as mine? And yours works well?!
I tried the example using three projects, Main, Main2 and Main3. None gave me the expected result. -
@tomy said in Problems in practicing and running an example:
Is it different from the "Qt Quick Console 2 Application" project?
No it is such project.
then added image{...} to ApplicationWindowApplicationWindow { visible: true width: 640 height: 480 title: qsTr("Hello World") Image { id: root source: "qrc:/images/test.png" } .....
test project
https://www.dropbox.com/s/kfkjb7c8dldvtr2/myqml.zip?dl=0 -
ApplicationWindow {
visible: true
width: 640
height: 480This part solved the issue.
test project
https://www.dropbox.com/s/kfkjb7c8dldvtr2/myqml.zip?dl=0Thanks.
-
@tomy
Ah so the sample had no window or something like that ? -
@mrjj
No unfortunately! Didn't you take a look at the website I offered?
I fear how I go on reading that book if its next examples are that vague! :-( -
@tomy
Yep. seems like a good book.
If you read it all, i think it will give lots of insights.
When you then know the classes and overall architecture, it should be easier to google
for other examples if needed.