tag:blogger.com,1999:blog-6145140879520785870.post1280112397039690549..comments2022-07-08T11:09:44.844+02:00Comments on thp on Maemo: Qt: Write once, #ifdef everywhere?thphttp://www.blogger.com/profile/04893729285856691511noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-6145140879520785870.post-1649136646482541052010-10-26T16:14:44.648+02:002010-10-26T16:14:44.648+02:00Thanks a lot for your solutions to this problem. I...Thanks a lot for your solutions to this problem. I wrote a pocket calculator app, which makes sense only in portrait-mode. <br /><br />i only did, what you explained, and it worked at the first try!!!Anonymoushttps://www.blogger.com/profile/13139240101639941672noreply@blogger.comtag:blogger.com,1999:blog-6145140879520785870.post-5497442675136603172010-10-09T00:00:56.235+02:002010-10-09T00:00:56.235+02:00Not to mention that #ifdefs are now in Qt code exa...Not to mention that #ifdefs are now in Qt code examples;<br /><br />http://wiki.forum.nokia.com/index.php/CS001504_-_Creating_an_SQLite_database_in_Qt<br /><br />I think that are many ways to avoid than. This Forum Nokia example is not well done IMO.Thiagohttps://www.blogger.com/profile/14022806302963762667noreply@blogger.comtag:blogger.com,1999:blog-6145140879520785870.post-8546725988336672002010-10-06T17:12:27.808+02:002010-10-06T17:12:27.808+02:00You can use QDesktopWidget to figure out the scree...You can use QDesktopWidget to figure out the screen size, no need to #ifdef it.Unknownhttps://www.blogger.com/profile/03240672522951450996noreply@blogger.comtag:blogger.com,1999:blog-6145140879520785870.post-3792309818169999802010-10-04T21:22:30.436+02:002010-10-04T21:22:30.436+02:00Funny, how "Qt-based" Symbian^3 still re...Funny, how "Qt-based" Symbian^3 still requires you to use Avkon to get things running :)fmshttps://www.blogger.com/profile/05421739300097844499noreply@blogger.comtag:blogger.com,1999:blog-6145140879520785870.post-80654363874926595882010-10-04T18:10:35.454+02:002010-10-04T18:10:35.454+02:00Meego makes this even worse. It's got a lot o...Meego makes this even worse. It's got a lot of Meego-only classes that have to used if you want your app to look like a true native Meego app.Alex Brownhttps://www.blogger.com/profile/06979311343180954697noreply@blogger.comtag:blogger.com,1999:blog-6145140879520785870.post-5103517884496131452010-10-04T15:40:07.566+02:002010-10-04T15:40:07.566+02:00Good post and good tips too. I just started to por...Good post and good tips too. I just started to port Qt desktop/Maemo5 application to Symbian and this is actually really helpful info.<br /><br />I use desktop version as a primary development version and of course I then miss all mobile device specific issues. But yeah, I have done some #ifdefs too already.<br /><br />And I do bet, that every developer has to go through all kinds of weird issues when writing and porting mobile Qt applications. Qt is great, but especially Symbian side seems to be a bit shaky still.Janihttps://www.blogger.com/profile/08379630690379791104noreply@blogger.comtag:blogger.com,1999:blog-6145140879520785870.post-40852168428421956682010-10-04T14:45:11.451+02:002010-10-04T14:45:11.451+02:00@the-new-andy: Sure, I'd probably put everythi...@the-new-andy: Sure, I'd probably put everything into a "Platform" class that I then subclass (and augment with platform-specific code) and use it as a singleton (with an instance of the platform-specific subclass returned) throughout my code. That's not the point, though - Qt should take care of some of these things for me.<br /><br />Having platform-specific code in a codebase gets tedious if you write (and maintain) multiple applications and want to have similar features in every one of them. Also, code isn't write-once, so when e.g. a bugfix or improvement is made to, say, the orientation-changing code, I have to copy it into every project.<br /><br />If this is abstracted by the toolkit, every application benefits from the bugfix as soon as it lands in the toolkit (and gets pushed out as an update). Also, if it's in the toolkit, I get support for new platforms for free (the Qt implementation in MeeGo Handset is able to do the right thing if I say "landscape only") instead of having to add even more code every time a new platform/device comes out.thphttps://www.blogger.com/profile/04893729285856691511noreply@blogger.comtag:blogger.com,1999:blog-6145140879520785870.post-70603183447013745132010-10-04T14:35:39.318+02:002010-10-04T14:35:39.318+02:00You might find yourself a bit happier you drop all...You might find yourself a bit happier you drop all of those #ifdefs and make an abstraction everywhere you are tempted to use one. You can then give different implementations living in completely different source files for each version.<br /><br />e.g. You could have an "orientation" abstraction, so you could do:<br /><br />#include "orientation.h"<br /><br />...<br /><br />orientation_set(ORIENTATION_FIXED | ORIENTATION_LANDSCAPE);<br /><br />in your main code. Then you have a:<br /><br />maemo5/orientation.c which for this case can do nothing.<br /><br />and a<br /><br />s3/orientation.c which has the code you included before.<br /><br />It tends to scale much nicer as you keep adding more and more platforms.Anonymousnoreply@blogger.com