Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

What does moc_mainwindow.cpp do?



  • What does moc_mainwindow.cpp do?
    I got many errors in moc_mainwindow when i compile

    I change a new Qt5.3.0 editor running previous version. I change the Forms but when run it reflects the same last form.



  • it seems that when i make changes to the Qt GUI, the code is not reflected. Why is this so?


  • Lifetime Qt Champion

    Hi,

    The moc files are generated from your headers containing QObject derived classes. What exact error are you getting ?



  • i deleted GUI dialogbox, and i need to manually remove the dialogbox under public slots in headers.h else there will be compiler error.


  • Lifetime Qt Champion

    Can you please show the code. Without it's pretty much impossible to tell what's going wrong.



  • I solved the problem by recreating every GUI from scratch again on QTcreator 5.3.1

    There is 2 problems:

    1. Firstly I used QTcreator(opensource) to create projectGUI. When i used QTcreator 5.3.1 to open projectGUI, make amendment to the GUI. I run it the GUI is always the one last created by QTcreator(opensource).
    2. I understand that creating a GUI, added a slot by going 'go to slot', i need to remove the GUI at the same time the slot in header file.


  • Can someone explain the sequence of how GUI is build?

    My understanding is the GUI creates the mainwindow header file that create moc_mainwindow.cpp that has the ability to display



  • This thing is bugging me continuously, ThreadMaster

    1>I created a label ObjectName Picture in mainwindow.ui
    2>I check mainwindow.ui updated this variable <good>
    3>I go into my cpp file ui-> , intellisense never appear ObjectName Picture
    <<<Why>>>
    4.when i compile, issues is Class UI::MainWindows has no member named label call Picture


  • Lifetime Qt Champion

    Before going further you should first have a look at the "designer quick start":http://qt-project.org/doc/qt-5/designer-quick-start.html guide and related examples.

    The object name property is not the same thing as the name you give to your widget.

    moc_mainwindow.cpp doesn't have that ability, the moc files contains the logic to make e.g. signals and slots working for your widget.


Log in to reply