Is Qt really cross-plattform ?



  • Sorry for this question. My goal is not to start a flame.
    I invoke your opniion and your experience with Qt, because I'm totally new in this world.

    I need to build a simple tool for windows Xp--->8.1 + os x 6/7 + linux

    Is it really already here a way to write-once and deploy-many ?
    Is there a way (It's a dream...) to cross-compile for windows + linux + mac using one single machine ?



  • Hmm, that's not really true of false to use only one machine. One machine with all the desired OS installed with Qt, then yes.
    And care should be taking when using system dependent API use, e.g. finding active windows etc in Windows doesn't have the same API code as in iOS so compiler switches are needed there.
    On the other hand your written program in Qt is transportable to different platforms to be compiled and run for that OS, so YES cross-platform.



  • yes , believe QT ! its really cross platform! if do not limit your application to a platform , for example if u use Regestry keys in windows for your application to save settings then your application cant run on linux or mac because they dont have this ....



  • @Jeroentje
    Do you mean that to compile for linux from windows I need a virtual machine?
    and to compile for ios from windows needs an other vm ?

    I know the problem of compiler switch and,( even I hate that in 2013 a framework at version 5 still have not uniform api, but... ) it's fully reasonable, every single way to cross-platform development has the same problem.



  • @Bepher, thanks. What you say it's right. A lot of cp-dev depends from ability of programmers to don't rely on system-specific feature, like registry keys of course.



  • I add a seconday question, but it's fully in-topic. Qt5.1 already can insomeway create windows 8 store app ?


  • Moderators

    Can you cross-compile? Yes, as long as you don't use platform-specific features and you have the right tools.

    Can you create Windows 8 store apps? "One day, you will be able to. But not yet.":http://blog.qt.digia.com/blog/2013/06/14/introduction-to-windows-rt-frameworks/



  • Hi, when you are trying to get something working on multiple platforms you absolutely must compile,run,test on the intended platform. You can not just compile,run on one platform and then say "it should work the same on the other platform".

    Even with the a really good cross-platform language such as html+javascript, you will run into problems where it won't work exactly the same on the different browsers.



  • [quote author="realtebo" date="1374131479"]@Jeroentje
    Do you mean that to compile for linux from windows I need a virtual machine?
    and to compile for ios from windows needs an other vm ?[/quote]

    At least that's how I do it and it is alot less time consuming and annoying than setting up and working with cross-compilation toolchains. After all, to test the resulting binary, you'll need the other OS anyway, right?

    [quote author="realtebo" date="1374131479"]I know the problem of compiler switch[/quote]

    Compiler switches aren't problems, they are solutions to else unsolvable problems.

    [quote author="realtebo" date="1374131479"]even I hate that in 2013 a framework at version 5 still have not uniform api, but...[/quote]

    Qt has a uniform API. It's just that some things are possible on some OS while they are not on other OS. In these cases, you will have to use the OS API (that has nothing to do with Qt), and that code will obviously be platform-dependent. Qt has an almost 100% uniform API for different OS, there are very very few methods in Qt that mention their behaviour differs from one OS to the other.



  • @DerManu + @1+1=2 1+1=2: 100% clear, and I agree.

    With 'switches problem' I, really, mean 'the switch question', .. i was not saying it's a problem, but "I know the story". Sorry :(

    About api: "finding active windows etc in Windows doesn’t have the same API code as in iOS" [from a Jeroentje reply]

    .. Is there NO way to do it using a common QT instrument ? or a simple thing like find active window require a os-specific development ?


  • Moderators

    If you Google "Qt find active window", you will find "the answer":http://qt-project.org/doc/qt-5.1/qtwidgets/qapplication.html#activeWindow



  • Really.. or in the doc there is no track of different behaviour with different oses, or the problem is not more here.
    3rd option: i've not understand what to read..



  • I am currently working on an application that I wish to run on Linux (my preferred platform) and Windows (because I expect a lot of the user base will be using that).

    I compile the application both on Linux and Windows 7 and all I have to do is delete one a single file, which is a platform specific configuration file, that is created with a couple of mouse clicks when you first open the project on the target platform. After that it will just compile and run (assuming the code is okay).

    The application works perfectly on both platforms I haven't tried iOS, because I don't have a Mac, though I am interested in possibly running it on Android.

    Qt is capable of dealing with the essential difference between the different OSes, it will cope with things like the slashes in the folder/path component separators if you use the / it will work happily on all platforms, without you having to worry about it.

    The Registry has been mentioned, because it only exists on MS platforms, but the QSettings class will save your configuration appropriately on the platform your code was compiled on.

    I use this to save my configuration and the settings are saved in the Registry on Windows and in a configuration file on Linux and the class does the work for you. Because I want the Application to be mobile I also give the user a choice to save the configuration in a file in the programs home folder on both platforms, so you can override if you wish.

    In the past I have written C++, using Visual Studio on MS and CodeBlocks on Linux and achieved the same with #defines switching out alternative bits of code, but in my experience Qt makes it very straight forward and so far I haven’t hit any problems.

    My comments talk about the ease of writing cross platform code, which I compile on the specific platforms, so I can’t comment on cross compiling.



  • Thanks, I appreciate much your post.

    Ho do you mantain a single code base beetween windows and linux machine ?

    I'm actively using git, and so I think to start from this: i create the project under git and develop under linux, at every bi-weekly alpha stage i commit and push the alpha on the remote and i pull from remote to my windows machine.

    I expect I can eventually do minor os fixes, recommit and compile on Windows, so substantially I'll use only a machine and my codebase is unique. If I'll get a Mac, git works great even under Mac.

    Is it good ?


  • Moderators

    git is definitely a good choice here.


  • Moderators

    [quote author="realtebo" date="1374137948"]Really.. or in the doc there is no track of different behaviour with different oses, or the problem is not more here.
    3rd option: i've not understand what to read..[/quote]The doc doesn't mention differences between OS'es, because there are no differences. QApplication::activeWindow() does the same thing on Windows and Linux and Mac :)


Log in to reply
 

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