Generate .h and .cpp from .ui file

左心房为你撑大大i 提交于 2019-11-30 05:12:29

If automatic generation does not work (like in my case) you can use uic to generate the header file manually. uic file.ui > file.h

You don't.
The about.ui generates a ui_about.h which you include in your own about.h

You then create you own class deriving from this class

class about :   public QDialog, public Ui::about
{
    Q_OBJECT;
....
}

Short answer:

In QtCreator there are two ways of create a form from windows assistant: - Qt Designer Form Class - QtDesigner Form

you must create a new "Qt Designer Form Class" instead of "Qt Designer Form", because you choose "Qt Designer Form" qt creator doesn't create the .h and .cpp from .ui file:

Long Answer:

When you create "QTCreator Form" only create .ui file this is useful if you already have an existing class for the UI business logic and you want rebuilt user interface but keep business logic, you can call buttom or components with same name and interchange ui.

QMake (actually uic) will automatically generate a ui_about.h file that you can use to make about.cpp (just make sure to get the .pro file right). Here's a tutorial

You might want to use the lastest Qt (4.6) too btw.

IN VS2008 Follow this step Go to Form Files->Add->Class->Qt4Classes->Q4GuiClass->Add , then Fill the class name and click on Finish.

zzl

if you are using qt creator in windows, just right click your project and click execute qmake, then it will generate a ui_xxx.h and you can add #include ui_xxx.h in your file.

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