How can i get c++ code from .ui file



  • hi, i have install Qt SDK version 1.1.4 , i am creating a empty qt project, then i am adding .ui file, now i then i run qmake, now i want to see c++ file created from that .ui file.



  • qmake (if .ui file is included in your .pro file) runs uic which creates ui_*.h file. Look for it in your project's build directory.



  • i look in build directory and i got ui_*.h file , but i am not able to see *.cpp file


  • Moderators

    There is simply no *.cpp file for compiled UI files. The header has enough information to create the GUI.

    All logic can be programmed in a separate class that uses the UI. See basically any Qt example, or even a generic stub generated by Qt Creator.



  • Hi Himan,

    I confirm what sierdzio said, all the information is on the ui_*.h file. The .cpp code you are looking for is inside the setupUi function. The ui class is divided in three parts:

    pointers to QObjects, QWidgets, etc definition

    setupUi Function

    retranslateUi Function

    You can say that the setupUi is your ui class constructor. It is the one that constructs the ui, check it out.

    Regards,
    Sebastian

    Edit: fixed up list layout; Andre


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.