Qt Designer generate C++ code

江枫思渺然 提交于 2019-12-22 14:05:41

问题


Is it possible to see C++ code with Qt Designer ? I can draw my interface and have it saved as a .ui file. Also, I can generate python code from .ui file using a .bat file. But I cannot view C++/Qt code generated from the UI, which I would like to get.

I looked for it and all I can find is doc. about how to generate the python from the .ui, which I can do but is not what I am looking for.

Thanks


回答1:


The menu item "Form/View Code" is exactly what you expect - it shows the generated C++ code:

As you can see from the comments in the generated file, Qt designer also uses uic (the Qt User Interface Compiler) to generate the code preview.

You can verify if uic works properly by manually creating the source code:

  • save your form to a .ui file, e.g. sample.ui
  • Run uic -o sample.h sample.ui from a command shell
  • sample.h then contains the generated source code


来源:https://stackoverflow.com/questions/16286166/qt-designer-generate-c-code

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