Convert Qt 4.7 to 4.2
Hey, I'm in a group for a compsci project at school. We need to write an interface in Qt. My group member wrote the GUI in Qt 4.7 an开发者_如何学JAVAd it needs to compile with Qt 4.2. When I try to qmake the project, it says "uic: File generated with too old of a version of Qt designer".
I'm new to Qt so I don't really know how much has changed between versions. My group member isn't being much help. Is there a painless way for me to convert the files to the right version of Qt?
The first thing I'd try is to open *.ui files in the old Qt Designer and try to save them. If it doesn't want to save a newly opened file, I'd make some insignificant changes like changing some property of some component to a different value and then back.
However, it may happen that Qt Designer will just complain about it being too old for that particular file, like UIC did. In this case you'll have to edit *.ui files by hand. They are plain XML files so it can be done relatively easy. First open them and change the version attribute to "4.2" or whatever is used by Qt 4.2 there in case it's different from the Qt version. Try to compile. UIC will probably complain about some properties that aren't supported by 4.2 or are specified in a different way. You'll have to either remove that properties if they aren't necessary or specify them in 4.2-compatible way. In order to figure out how to do it, create a simple UI from scratch, using that particular property, and save it to a new file. Open it and look how it was done in 4.2. Then edit your files to conform to that format.
I did this in the past (not exactly 4.7 to 4.2 though), and it was easier than it sounds. I just had to change the way a few properties were specified. Margins or something like that, I don't remember exactly. I even was able to do it with a regular expression replace I think.
I did this today and it looks like newer designer .ui files have this line at the top:
<?xml version="1.0" encoding="UTF-8"?>
If you remove this line the next line should be something like:
<ui version="4.0">
Then qmake and uic should work correctly.
The problem is the .ui files. Try opening them in Qt designer and getting it to convert them.
精彩评论