Author Topic: [QT] Customize compilation for ui  (Read 7938 times)

karl

  • Guest
[QT] Customize compilation for ui
« on: October 09, 2005, 03:00:09 pm »
Hello all,

first of all, congrat' for Code::Blocks, it's really easy to install and user friendly.  :D

I begin to build a QT project inside CodeBlock. What I've done till now is to use the QT uic compiler outside CodeBlock and add the resulted H file to my project.
Now I would like that to be directly done inside CodeBlock.
I tried following:
I added the ui to the project
I added the following line in
Code
C:\Qt\4.0.1\bin\uic.exe ($DIR)\($NAME).ui -o ($DIR)\($NAME)_ui.h
in Build tab of Options dialog.
In Compile tab, I ticked the box "Compile File" and "Link file".

What I expected then is that the contextual menu on my UI file will enable me to choose the item "Compile" as it is currently for a CPP file for instance.

Did I miss something? Is it the way it is supposed to work?

Thanks in advance for any hint, any help.

Cheers,
Karl.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: [QT] Customize compilation for ui
« Reply #1 on: October 09, 2005, 04:24:05 pm »
Hmm, I really have no idea what uic is or what it does, nor how to use it.

But anyway, if I understand what it does correctly (takes some input and creates some headers that your program then includes), you may want to enter this line into "pre-build" steps under the "Commands" tab in the build options. Then it is called every time before the actual build starts, so the necessary headers should be created.

If uic takes an awful long time and you don't want it to run every time, you can either make a shell script and use test to only invoke uic when the input files are modified, or you can add uic under the "Tools" menu and do everything manually when necessary.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

karl

  • Guest
Re: [QT] Customize compilation for ui
« Reply #2 on: October 09, 2005, 04:55:13 pm »
Hi Thomas,

thanks for your help.
uic is the User Interface Compiler from QT. You understand correctly what it does, it takes as input a UI file constructed with QT Designer and produces a header that I include in my project to display a customized dialog for instance.

So I did what you tell me and it works fine. Nevertheless some small things are bizarre:
The H file is correctly generated although CodeBlock writes the message:
Quote
"Could not create output file"
.
The H file is not always refreshed in the CodeBlock view, some times I get the dialog "Your file has been modified outside Code::Block... etc" but not always.

And, for the future, it should be nicer to be able to call a custom compiler on specific files rather than using this Pre-build steps feature that is certainly well adapted for some use, but not for this one.

Thanks again for your Help,

cheers,
Karl.


karl

  • Guest
Re: [QT] Customize compilation for ui
« Reply #3 on: October 09, 2005, 05:10:27 pm »
 :? oops, in fact, the H file is well generated but the error message I get is apparently related to the exe file generation. So I cannot get my generation work anymore and even if I remove the command line in the pre-build. I don't see what I changed that could cause that. I think I only renamed some files, but I readded them to the project... so I don't see where the mess comes from.

Karl.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: [QT] Customize compilation for ui
« Reply #4 on: October 09, 2005, 05:20:31 pm »
Look in Taskmanager. Probably the program was abnormally terminated and is still running, so the application image is still locked. Kill the process.

About the header file not changing in the editor:
This is normal, it should not update. Code::Blocks may ask you whether to reload it, but should never do it secretly (and it only checks at discrete times).
Apart from that, you should NEVER open an automatically generated file in an editor at all.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

karl

  • Guest
Re: [QT] Customize compilation for ui
« Reply #5 on: October 09, 2005, 05:29:46 pm »

Thanks once again Thomas.

Actually the problem was following:
In the Project's Build Options dialog I add defined a command line at 2 levels: one at "QT Application" and one at its child "default". The one in "default" was not correct and was preventing the exe file to be generated.

As for opening an automatically generated file, I disagree, I like to see what is generated and it can be usefull for debugging as well. But it's Ok, I see how CodeBlocks works, and if I want to force the reloading, I just have to close the file and to reopen it.

Regards,
Karl.