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 we have Hot Reload or Live coding for C++ based apps ?

Can we have Hot Reload or Live coding for C++ based apps ?

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 4 Posters 1.6k 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.
  • T Offline
    T Offline
    tataeress
    wrote on 3 Feb 2023, 09:17 last edited by tataeress 2 Mar 2023, 09:18
    #1

    Hi,
    I've noticed that we have Qml live coding for years now as well as for QML based apps that uses components written in C++.
    also, there are game engines like Unreal that support hot reload and I was thinking..
    Why can't we code apps in C++ only with Qt Widgets for example, but, with live coding / hot reload ?

    J C 2 Replies Last reply 3 Feb 2023, 11:52
    1
    • T tataeress
      3 Feb 2023, 09:17

      Hi,
      I've noticed that we have Qml live coding for years now as well as for QML based apps that uses components written in C++.
      also, there are game engines like Unreal that support hot reload and I was thinking..
      Why can't we code apps in C++ only with Qt Widgets for example, but, with live coding / hot reload ?

      J Offline
      J Offline
      JonB
      wrote on 3 Feb 2023, 11:52 last edited by JonB 2 Mar 2023, 11:54
      #2

      @tataeress
      What do your other IDE's do for "live coding / hot reload" in the context of a C++ (compiled) program?
      I would hate to think it does some kind of re-compile/link every time I change a character in a header file....

      1 Reply Last reply
      0
      • T tataeress
        3 Feb 2023, 09:17

        Hi,
        I've noticed that we have Qml live coding for years now as well as for QML based apps that uses components written in C++.
        also, there are game engines like Unreal that support hot reload and I was thinking..
        Why can't we code apps in C++ only with Qt Widgets for example, but, with live coding / hot reload ?

        C Offline
        C Offline
        Chris Kawa
        Lifetime Qt Champion
        wrote on 3 Feb 2023, 14:40 last edited by
        #3

        @tataeress said:

        Why can't we code apps in C++ only with Qt Widgets for example, but, with live coding / hot reload ?

        You can. You just need an IDE that supports it. For example you can hot reload widgets app in VS2022 with no problem.

        T 1 Reply Last reply 4 Feb 2023, 11:19
        1
        • C Chris Kawa
          3 Feb 2023, 14:40

          @tataeress said:

          Why can't we code apps in C++ only with Qt Widgets for example, but, with live coding / hot reload ?

          You can. You just need an IDE that supports it. For example you can hot reload widgets app in VS2022 with no problem.

          T Offline
          T Offline
          tataeress
          wrote on 4 Feb 2023, 11:19 last edited by tataeress 2 Apr 2023, 11:20
          #4

          @Chris-Kawa I tried, but it doesn't work
          The hot reload button just does nothing

          C 1 Reply Last reply 4 Feb 2023, 12:52
          0
          • T tataeress
            4 Feb 2023, 11:19

            @Chris-Kawa I tried, but it doesn't work
            The hot reload button just does nothing

            C Offline
            C Offline
            Chris Kawa
            Lifetime Qt Champion
            wrote on 4 Feb 2023, 12:52 last edited by
            #5

            @tataeress I just tried and it works ok. Added a function call, changed some parameters around, modified member values etc.

            Not all types of changes are supported: Supported Code Changes (C++).
            What kind of chang are you trying to make for example?

            T 1 Reply Last reply 4 Feb 2023, 14:44
            1
            • C Chris Kawa
              4 Feb 2023, 12:52

              @tataeress I just tried and it works ok. Added a function call, changed some parameters around, modified member values etc.

              Not all types of changes are supported: Supported Code Changes (C++).
              What kind of chang are you trying to make for example?

              T Offline
              T Offline
              tataeress
              wrote on 4 Feb 2023, 14:44 last edited by
              #6

              @Chris-Kawa oh right, my changes were within the static library that contains all the code of the app since I wanted to make it easy to do unit tests also.
              And I'm making the app executable using htat static library that has all the code
              According to the documentation you linked, I can't make changes to a static library and expect hot reloading to work xD
              Thx a lot!

              T 1 Reply Last reply 4 Feb 2023, 17:03
              0
              • T tataeress
                4 Feb 2023, 14:44

                @Chris-Kawa oh right, my changes were within the static library that contains all the code of the app since I wanted to make it easy to do unit tests also.
                And I'm making the app executable using htat static library that has all the code
                According to the documentation you linked, I can't make changes to a static library and expect hot reloading to work xD
                Thx a lot!

                T Offline
                T Offline
                tataeress
                wrote on 4 Feb 2023, 17:03 last edited by
                #7

                @tataeress Actually changing the app from a library linked to a main.cpp executable to a full executable, whatever I change in code nothing happens at all
                I changed code in main.cpp, modifying the app's main class constructor, slots .. added new functions, modified variables ..
                its all getting ignored ..

                C 1 Reply Last reply 4 Feb 2023, 21:08
                0
                • T tataeress
                  4 Feb 2023, 17:03

                  @tataeress Actually changing the app from a library linked to a main.cpp executable to a full executable, whatever I change in code nothing happens at all
                  I changed code in main.cpp, modifying the app's main class constructor, slots .. added new functions, modified variables ..
                  its all getting ignored ..

                  C Offline
                  C Offline
                  Chris Kawa
                  Lifetime Qt Champion
                  wrote on 4 Feb 2023, 21:08 last edited by
                  #8

                  @tataeress Start with a basic wizard generated widgets app and test if that works for you.

                  T 1 Reply Last reply 5 Feb 2023, 07:20
                  0
                  • C Chris Kawa
                    4 Feb 2023, 21:08

                    @tataeress Start with a basic wizard generated widgets app and test if that works for you.

                    T Offline
                    T Offline
                    tataeress
                    wrote on 5 Feb 2023, 07:20 last edited by tataeress 2 May 2023, 18:52
                    #9

                    @Chris-Kawa
                    Actually it worked once I did:

                    • Switch to RelWithDebugInfo instead of Release mod
                    • Go to the Project Properties > C/C++ > General > Debug Information Format and chose Program Database for Edit And Continue
                    • Replace qt_add_executable in my CMakeLists.txt to add_executable while keeping the same arguments
                    • Added this before the add_executable
                    if (MSVC AND WIN32 AND NOT MSVC_VERSION VERSION_LESS 142)
                    
                        add_link_options($<$<CONFIG:RelWithDebugInfo>:/INCREMENTAL>)
                        add_compile_options($<$<CONFIG:RelWithDebugInfo>:/ZI>)
                    
                    endif()
                    

                    Thx a lot!

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      Stefan Reinalter
                      wrote on 5 May 2023, 18:59 last edited by
                      #10

                      On Windows, you can license Live++: https://liveplusplus.tech

                      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