how to create a main.moc file??
how to create a main.moc file??
you need to create object deriven from QObject and then regenerate project, i.e. call qmake.
Qt Assistant -- rocks!
please, use tags [CODE] & [/CODE].
hi,
could u please provide me with an example??
Thanks
yesterday example
add this code to yours main.cpp, clean your project and then call qmake. now, when you start compilation main.com will be generated.Qt Code:
#include <QTimer> #include <QApplication> { Q_OBJECT public: { connect(&m_timer, SIGNAL(timeout()), SLOT(updateEvents())); m_timer.setInterval(100); m_timer.start(); } private slots: void updateEvents() { m_timer.start(); qApp->processEvents(); } private: QTimer m_timer; }; #include "main.moc" int main(int argc, char **argv) { MyProcessEventDispatcher mpee; //... return app.exec(); }To copy to clipboard, switch view to plain text mode
Qt Assistant -- rocks!
please, use tags [CODE] & [/CODE].
Qt Code:
// main.cpp { // no Q_OBJECT macro here }; int main() { } #include "main.moc" // moc file included by hand, but there is nothing for moc to generateTo copy to clipboard, switch view to plain text mode
vs.
Qt Code:
// main.cpp { Q_OBJECT // macro exists }; int main() { } #include "main.moc" // moc file included by hand, moc generates meta object code for "Object"To copy to clipboard, switch view to plain text mode
J-P Nurmi
hi guys,
thanks for clearing that up..i have another query..i m trying smth like this from main.cpp
now this, wont connect cuz processEvents() isnt actually a slot..is there any possible way i can call qApp->processEvents() from main.cpp on timeout of a timer..it would be great help if u can help me solve this..
thanks in advance!
I've posted an example how to do this. why you can't use it? it solves you problem.![]()
Qt Assistant -- rocks!
please, use tags [CODE] & [/CODE].
buddy, i tried that..in ur case, updateEvents() was called only once..no more than that..so i just wanted to try this as the last option..or i'll just give this problem to sm1 else..
in your case (which you try to achive) you will have the same behavior, because yours "have"-comp block event loop! so, there is no difference between your code (what you try to achive) and my!
Qt Assistant -- rocks!
please, use tags [CODE] & [/CODE].
Bookmarks