Advice about deploying with extra files
I'm looking for a little advise as I seem to have confused myself a little.
I'm deploying a Windows application and I have put a picture as a background. I've done this using QPalette -> set Brush -> QImage then the file name of the picture. In the installer program I can specify where I want the picture to be so that the Qt program can find it.
My problem is where should I put it, I tried putting in the 'pictures' folder as I could use QDesktopservices:: folder location to find the file in the pictures folder... but then multiple users of the computer can use the program but then not have access to the picture.
I'm obviously doing this wrong, could someone give me a pointer as to the correct way to do this.
Are you using Qt for Desktop?
Then the resource editor is your friend. This link shows how you can add files like images to your project.
Ah thats great, I thought there must be a way to add things like pictures to projects. Many Thanks
Thanks for the pointer, I think I'm close. I now have a resource file and I can set the style sheet to reference that so now, when I look in Qt Creator and select the form, I can see the image as the background. However, if I run the program I just get the normal grey background. I've tried rebuilding and cleaning etc but still just the grey background.
What step have I missed?
can you give us the stylesheet code you used or what you used in Qt Creator?
in Qt Creator, right clicked on project, add new, Qt Resource file, chose name, added to project. Then chose prefix and added file. Save.
Open the form - selected main window, on right menu, property -> style sheet.
In the edit style sheet, add resource, and then background-image: url(:/new/prefix1/IMAGE.jpg);
Now the form has the wonderful IMAGE as the background, until I hit build... then it doesnt.
if i do the same i see the image in both my preview as when i build it.
what version do you have of Qt and Qt Creator?
menu help < about Qt Creator. There you will see both versions.
Qt Creator 2.0.1
Based on Qt 4.7.0 (32 bit)
i'm on Qt Creator 2.2 Based on Qt 4.7.4 (64 bit)
you could search bug tracker to see if there is ann issue. obviously it's resolved in my later version.
"use this link :http://developer.qt.nokia.com/contribute
I've tried it on a new file and it works. It seems I have a ui header file that is over-riding any work i do on the form. Is there a way to create a new header file for the form? or a way to delete the header file?
If you delete the ui header file in windows explorer and build again?
I get the error message:
No rule to make target '.. ui_MYPROJECT.h', needed by 'debug/MYPROJECT.o'. Stop
Delete your build directory or use Qt Creator > clean.
Run qmake again and build.
I did Build-> Clean All, then Run qmake, then Build All.... the header file is unfortunately the same. Grr
There must be something else going on. Can you use your ui file in a newly created project and see what happens then?
Unfortunately nothing, it seems the header file is overwriting any changes I make to the ui form. for example if I edit the ui header file and change the window title... then it changes. I've tried copying to a new file but I get a hundred odd error messages saying:
"invalid use of incomplete type 'struct Ui::MYPROJECT'"
forward declaration of 'struct Ui::MYPROJECT'
am just about getting ready to throw my computer out of the window
Normally you do nothing in the ui header file. Qt generates it for you.
Did you alter things there before?
If you clean your project it shouldn't be there anymore.
Did you delete it in windows explorer? Make sure it's deleted before running qmake and building again