Qt : How to generate .h and .cpp from a .ui file - Vim and Qt is it practical?

拈花ヽ惹草 提交于 2021-01-28 23:00:13

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!