问题
I have been using Qt
for a while in Windows
with Visual Studio
on Windows using the Qt Addin
.
For creating forms I would use Qt Designer
and when I would save the form which I would get a *.ui
file, a *.cpp
file and a *.h
file. Now on GNU/Linux
I plan to use Vim
for development. I could create Qt
based programs using Vim
however I would like to design forms using Qt Designer
and integrate the saved *.ui
file into my project and use those forms. How can I use the *.ui
designed form in my C++
project?
回答1:
Use uic
to compile the .ui file would do. Some instruction here. You can also use qtcreator on linux, which includes the vim editing mode plugin.
回答2:
AFAIK if you add all your files to your *.pro
project file, qmake
it and compile the result with cl
everything should work fine. Just for the task of processing *.ui
files you can use the Qt UI Compiler.
From experience I would say that trying to use Vim
this way is a real challenge and I wish you good luck with that. In case you change your mind maybe you should know that Qt Creator
has a Vim
mode called FakeVim, maybe you should take a look at that as well.
Update:
You don't create a header file that inherits from the generated header, you create a class that inherits from or uses the generated class. Considering that, I would really recommend you use Qt Creator
or, if you really want Vim
, use FakeVim
. Using Vim
in this situation is hard and if you're not an advanced, or at least intermediate Vim
user you will find it very painful. Vim is powerful but hard to setup for beginners. You will need plug-ins for autocomplete, project tree or neat jumps from header to source just to name a few and setting these up is not very user friendly/straight forward.
My advice: Use Qt Creator
or FakeVim
.
来源:https://stackoverflow.com/questions/26989441/qt-how-to-generate-h-and-cpp-from-a-ui-file-vim-and-qt-is-it-practical