Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Can I write one code for all platforms ?
Forum Updated to NodeBB v4.3 + New Features

Can I write one code for all platforms ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
17 Posts 3 Posters 1.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • AhtiA Offline
    AhtiA Offline
    Ahti
    wrote on last edited by
    #1

    Hi
    Is it possible to write one code for all platforms ? it should run on desktop ( all OS ) and on mobile as well ( all OS ) ?

    what is a signature ?? Lol

    jsulmJ J.HilkJ 2 Replies Last reply
    0
    • AhtiA Ahti

      Hi
      Is it possible to write one code for all platforms ? it should run on desktop ( all OS ) and on mobile as well ( all OS ) ?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Ahti Yes, this is what Qt is for.
      But if you want to support that many platforms (all Desktop, all mobile, what does - "all" even mean?) then you will need some platform specific code as well.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      AhtiA 1 Reply Last reply
      4
      • AhtiA Ahti

        Hi
        Is it possible to write one code for all platforms ? it should run on desktop ( all OS ) and on mobile as well ( all OS ) ?

        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by
        #3

        hi @Ahti

        yes it's possible with Qt to have one code base for all supported platforms.

        However you have to do some differentiations between the OS's

        Qt offers Macros for your source code( for example ) and your pro file for that purpose ( for example )


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        1 Reply Last reply
        3
        • jsulmJ jsulm

          @Ahti Yes, this is what Qt is for.
          But if you want to support that many platforms (all Desktop, all mobile, what does - "all" even mean?) then you will need some platform specific code as well.

          AhtiA Offline
          AhtiA Offline
          Ahti
          wrote on last edited by
          #4

          @jsulm @J.Hilk so I can run the deployed app on desktop as well as on mobile with some specific changes ?

          what is a signature ?? Lol

          jsulmJ 1 Reply Last reply
          0
          • AhtiA Ahti

            @jsulm @J.Hilk so I can run the deployed app on desktop as well as on mobile with some specific changes ?

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by jsulm
            #5

            @Ahti Yes. But you will build you app for each supported platform. Qt is a C++ framework, that means your app is build for a platform as binary which directly runs on the CPU. This is a difference to Java. Java apps are build once for the JVM and run on all platforms where the JVM is available. Qt is "Code once build everywhere".

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            AhtiA 1 Reply Last reply
            3
            • jsulmJ jsulm

              @Ahti Yes. But you will build you app for each supported platform. Qt is a C++ framework, that means your app is build for a platform as binary which directly runs on the CPU. This is a difference to Java. Java apps are build once for the JVM and run on all platforms where the JVM is available. Qt is "Code once build everywhere".

              AhtiA Offline
              AhtiA Offline
              Ahti
              wrote on last edited by
              #6

              @jsulm Do I have to start my projects by select Qt Widgets Application for that purpose ?
              and later on add the specific code ?

              what is a signature ?? Lol

              jsulmJ J.HilkJ 2 Replies Last reply
              0
              • AhtiA Ahti

                @jsulm Do I have to start my projects by select Qt Widgets Application for that purpose ?
                and later on add the specific code ?

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @Ahti If you want to write a GUI application using widgets then yes. You should also consider using QML as it is better suited for mobile apps (and can be used for desktop apps as well).

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                3
                • AhtiA Ahti

                  @jsulm Do I have to start my projects by select Qt Widgets Application for that purpose ?
                  and later on add the specific code ?

                  J.HilkJ Offline
                  J.HilkJ Offline
                  J.Hilk
                  Moderators
                  wrote on last edited by
                  #8

                  @Ahti
                  +1 to @jsulm answer,

                  For cross platform (desktop and mobile in this case) I would highly recommend using QML for your UI/frontend. As it comes with native GPU support. Very noticeable for mobile apps.

                  You can force that also via QWidgets, but you'll have to go the extra mile to set it up and use it.


                  Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                  Q: What's that?
                  A: It's blue light.
                  Q: What does it do?
                  A: It turns blue.

                  AhtiA 1 Reply Last reply
                  1
                  • J.HilkJ J.Hilk

                    @Ahti
                    +1 to @jsulm answer,

                    For cross platform (desktop and mobile in this case) I would highly recommend using QML for your UI/frontend. As it comes with native GPU support. Very noticeable for mobile apps.

                    You can force that also via QWidgets, but you'll have to go the extra mile to set it up and use it.

                    AhtiA Offline
                    AhtiA Offline
                    Ahti
                    wrote on last edited by
                    #9

                    @J.Hilk @jsulm Why do I get No valid kits found while creating a new Qt Quick Application (Empty) in Qt5.9

                    what is a signature ?? Lol

                    J.HilkJ 1 Reply Last reply
                    0
                    • AhtiA Ahti

                      @J.Hilk @jsulm Why do I get No valid kits found while creating a new Qt Quick Application (Empty) in Qt5.9

                      J.HilkJ Offline
                      J.HilkJ Offline
                      J.Hilk
                      Moderators
                      wrote on last edited by
                      #10

                      @Ahti because no valid kits were found of course...

                      More information please, did you install the precompiled libs ? are they found, what warnings/errors do you have in your kits section of QtCreator options ?


                      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                      Q: What's that?
                      A: It's blue light.
                      Q: What does it do?
                      A: It turns blue.

                      AhtiA 1 Reply Last reply
                      1
                      • J.HilkJ J.Hilk

                        @Ahti because no valid kits were found of course...

                        More information please, did you install the precompiled libs ? are they found, what warnings/errors do you have in your kits section of QtCreator options ?

                        AhtiA Offline
                        AhtiA Offline
                        Ahti
                        wrote on last edited by Ahti
                        #11

                        @J.Hilk Here is my kits section configuration:

                        0_1557741230966_Qt kit.PNG

                        And I Just installed Qt 5.9 from its setup.

                        what is a signature ?? Lol

                        J.HilkJ 1 Reply Last reply
                        0
                        • AhtiA Ahti

                          @J.Hilk Here is my kits section configuration:

                          0_1557741230966_Qt kit.PNG

                          And I Just installed Qt 5.9 from its setup.

                          J.HilkJ Offline
                          J.HilkJ Offline
                          J.Hilk
                          Moderators
                          wrote on last edited by
                          #12

                          @Ahti
                          No, it seems like you only installed QtCreator and (maybe) the MinDW complier tool.

                          You're missing any precompiled Qt Libs.
                          I would suggest opened the maintenanceTool and installing a Qt version from there (5.9.x the latest LTS or the latest 5.12)


                          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                          Q: What's that?
                          A: It's blue light.
                          Q: What does it do?
                          A: It turns blue.

                          AhtiA 1 Reply Last reply
                          1
                          • J.HilkJ J.Hilk

                            @Ahti
                            No, it seems like you only installed QtCreator and (maybe) the MinDW complier tool.

                            You're missing any precompiled Qt Libs.
                            I would suggest opened the maintenanceTool and installing a Qt version from there (5.9.x the latest LTS or the latest 5.12)

                            AhtiA Offline
                            AhtiA Offline
                            Ahti
                            wrote on last edited by Ahti
                            #13

                            @J-Hilk What I can remember after installing Qt 5.9 I downloaded a new version of Qt Creator and replaced it with one already included with Qt 5.9 could that be the culprit also I tried update component of maintenanceTool but that gives me At least one valid and enable repository required for this action to succeed error. Would reinstalling Qt5.9 help ?

                            what is a signature ?? Lol

                            jsulmJ 1 Reply Last reply
                            0
                            • AhtiA Ahti

                              @J-Hilk What I can remember after installing Qt 5.9 I downloaded a new version of Qt Creator and replaced it with one already included with Qt 5.9 could that be the culprit also I tried update component of maintenanceTool but that gives me At least one valid and enable repository required for this action to succeed error. Would reinstalling Qt5.9 help ?

                              jsulmJ Offline
                              jsulmJ Offline
                              jsulm
                              Lifetime Qt Champion
                              wrote on last edited by
                              #14

                              @Ahti You should really use online installer. Then you will have Qt Maintenance Tool which you can use to add/remove Qt versions, update Qt and QtCreator.

                              https://forum.qt.io/topic/113070/qt-code-of-conduct

                              AhtiA 2 Replies Last reply
                              0
                              • jsulmJ jsulm

                                @Ahti You should really use online installer. Then you will have Qt Maintenance Tool which you can use to add/remove Qt versions, update Qt and QtCreator.

                                AhtiA Offline
                                AhtiA Offline
                                Ahti
                                wrote on last edited by
                                #15

                                @jsulm Thanks for your time. But reinstalling helped :D

                                what is a signature ?? Lol

                                1 Reply Last reply
                                0
                                • jsulmJ jsulm

                                  @Ahti You should really use online installer. Then you will have Qt Maintenance Tool which you can use to add/remove Qt versions, update Qt and QtCreator.

                                  AhtiA Offline
                                  AhtiA Offline
                                  Ahti
                                  wrote on last edited by
                                  #16

                                  @jsulm Btw I still have Maintenance Tool with offline installer but its showing error with update components even after reinstalling.

                                  what is a signature ?? Lol

                                  J.HilkJ 1 Reply Last reply
                                  0
                                  • AhtiA Ahti

                                    @jsulm Btw I still have Maintenance Tool with offline installer but its showing error with update components even after reinstalling.

                                    J.HilkJ Offline
                                    J.HilkJ Offline
                                    J.Hilk
                                    Moderators
                                    wrote on last edited by
                                    #17

                                    @Ahti said in Can I write one code for all platforms ?:

                                    offline installer

                                    Theres' the problem

                                    The offline installer does not allow for updates or later removals/addons.
                                    You should use the online installer.

                                    The offline one is more of a last resort kind of deal, when the online one doesn't work at all ;-)


                                    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                                    Q: What's that?
                                    A: It's blue light.
                                    Q: What does it do?
                                    A: It turns blue.

                                    1 Reply Last reply
                                    1

                                    • Login

                                    • Login or register to search.
                                    • First post
                                      Last post
                                    0
                                    • Categories
                                    • Recent
                                    • Tags
                                    • Popular
                                    • Users
                                    • Groups
                                    • Search
                                    • Get Qt Extensions
                                    • Unsolved