Separation, MVC, Threads and signal-slots

In Qt you can't display anything from other than the Gui thread.

I didn't know this.

In Qt you need to set the GUI class parent to the thread class to access the Main GUI Thread.

I didn't know this.

In fact I didn't know much about the current thing that I was working on. So 1. I tried to use threads to directly modify the GUI. Failed with aborts! 2. Wrote a wrapper in main that would modify the gui and called it by setting main class as parent. Still there are aborts. Then spent some time thinking about alternative solutions. And found some stuff about inter-thread communication. So stumbled upon solution of using Signal-Slots for inter-thread communication. Got a lot of weird errors involving MOC and stuff.
Further googling and furious search led to the pristine knowledge that we need a Q_OBJECT macro when we have a signal in a class. OK. Put in the macro; still more errors! Ok some more googling, and came to know that we need to qmake it all. OK, so after a super clean build, I had it all working and the UI was updated.

So now it all looks like a big hell of a mess and I need to clean it all up. So some more googling and I came to know about MVC thingie. Took me couple of days to completely understand it. ( Actually I still don't know if I have groked it all, but whatever I have consumed, works!!!) So after this, there were few days of equally furious and confused refactoring, some scope jumbles and lot of commenting around to keep track of everything. And finally, I got it all working.

I'll still need to clear it up into a separate project which I can present as a module, but this was a fortnight of intensive learning. Working on new stuff is always so interesting!

Comments

Popular posts from this blog

Morning Quotes

QCalendarWidget CSS Stylesheeting