May 31, 2011

crispylx crispylx
Lab Rat
13 posts

Advice about deploying with extra files

Page  
1

Hi all,

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.

Many thanks

Chris

16 replies

May 31, 2011

Eddy Eddy
Gene Splicer
1296 posts

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.
http://doc.trolltech.com/4.7/designer-resources.html [doc.trolltech.com]

 Signature 

Qt Certified Specialist
Qt Ambassador

May 31, 2011

crispylx crispylx
Lab Rat
13 posts

Ah thats great, I thought there must be a way to add things like pictures to projects. Many Thanks

June 4, 2011

crispylx crispylx
Lab Rat
13 posts

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?
Chris

June 4, 2011

Eddy Eddy
Gene Splicer
1296 posts

can you give us the stylesheet code you used or what you used in Qt Creator?

 Signature 

Qt Certified Specialist
Qt Ambassador

June 4, 2011

crispylx crispylx
Lab Rat
13 posts

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.

Thanks Eddy.

June 4, 2011

Eddy Eddy
Gene Splicer
1296 posts

that’s strange.
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.

 Signature 

Qt Certified Specialist
Qt Ambassador

June 4, 2011

crispylx crispylx
Lab Rat
13 posts

Qt Creator 2.0.1
Based on Qt 4.7.0 (32 bit)

June 4, 2011

Eddy Eddy
Gene Splicer
1296 posts

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
.

 Signature 

Qt Certified Specialist
Qt Ambassador

June 4, 2011

crispylx crispylx
Lab Rat
13 posts

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?

June 5, 2011

Eddy Eddy
Gene Splicer
1296 posts

If you delete the ui header file in windows explorer and build again?

 Signature 

Qt Certified Specialist
Qt Ambassador

June 5, 2011

crispylx crispylx
Lab Rat
13 posts

I get the error message:

No rule to make target ‘.. ui_MYPROJECT.h’, needed by ‘debug/MYPROJECT.o’. Stop

June 5, 2011

Eddy Eddy
Gene Splicer
1296 posts

Delete your build directory or use Qt Creator > clean.

Run qmake again and build.

 Signature 

Qt Certified Specialist
Qt Ambassador

June 5, 2011

crispylx crispylx
Lab Rat
13 posts

I did Build-> Clean All, then Run qmake, then Build All…. the header file is unfortunately the same. Grr

June 5, 2011

Eddy Eddy
Gene Splicer
1296 posts

There must be something else going on. Can you use your ui file in a newly created project and see what happens then?

 Signature 

Qt Certified Specialist
Qt Ambassador

June 5, 2011

crispylx crispylx
Lab Rat
13 posts

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’”
or
forward declaration of ‘struct Ui::MYPROJECT’

am just about getting ready to throw my computer out of the window

Page  
1

  ‹‹ [Solved] How to create QDockWidget?      Debugging resource loss ››

You must log in to post a reply. Not a member yet? Register here!