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. QT with Visual Studio
Forum Updated to NodeBB v4.3 + New Features

QT with Visual Studio

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 4 Posters 1.1k 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.
  • A Offline
    A Offline
    Asphodelus
    wrote on last edited by Asphodelus
    #1

    Hello all,

    I do small apps with QtCreator, but for various reasons, I want to use Visual Studio with Qt Designer for the .ui

    I can do an app with .ui file BUT, no way to retrieve the objects contained in this ui file (while it's so simple with QtCreator...)
    alt text
    Any idea?

    Thanks in advance :)
    Julien

    jsulmJ 1 Reply Last reply
    0
    • A Asphodelus

      Hello all,

      I do small apps with QtCreator, but for various reasons, I want to use Visual Studio with Qt Designer for the .ui

      I can do an app with .ui file BUT, no way to retrieve the objects contained in this ui file (while it's so simple with QtCreator...)
      alt text
      Any idea?

      Thanks in advance :)
      Julien

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

      @Asphodelus Take a look at https://doc.qt.io/archives/vs-addin/index.html

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

      1 Reply Last reply
      3
      • A Offline
        A Offline
        Asphodelus
        wrote on last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • A Offline
          A Offline
          Asphodelus
          wrote on last edited by Asphodelus
          #4

          Thanks! I can use ui.my_widget. doSomething();
          BUT... :(

          In Qt Designer, I create a button called "foo", it"s working, i can do: ui.foo->setText("blabla);, But if for example I want to rename it to "bar" in QT Desinger, Visual Studio don't update this (I've tried regenerate solution etc...)

          A little example here with the button named "bar" in the *ui

          https://www.noelshack.com/2020-50-3-1607540469-capture.jpg

          1 Reply Last reply
          0
          • O Offline
            O Offline
            ollarch
            wrote on last edited by
            #5

            Hi,

            As the UI is modified externally using QDesigner, Visual Studio does not know that the UI has changed. After saving the UI in QDesigner right click on the UI file on Visual Studio solution explorer and compile the file. The UIC compiler will regenerate the "ui_XXX.h" file that is the file that your application is looking for.

            JonBJ 1 Reply Last reply
            1
            • O ollarch

              Hi,

              As the UI is modified externally using QDesigner, Visual Studio does not know that the UI has changed. After saving the UI in QDesigner right click on the UI file on Visual Studio solution explorer and compile the file. The UIC compiler will regenerate the "ui_XXX.h" file that is the file that your application is looking for.

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #6

              @ollarch
              Indeed that will be the OP's issue. But is there any way (I don't know or use VS) to tell the VS project that the ui....h file depends on the .ui file, and run the necessary uic to regenerate it, so that you know you can build in VS and it will update automatically?

              EDIT Hmm, I see this is asked in https://stackoverflow.com/questions/60304171/cmake-qt5-and-autouic-not-rebuilding-when-ui-file-touched

              O 1 Reply Last reply
              0
              • JonBJ JonB

                @ollarch
                Indeed that will be the OP's issue. But is there any way (I don't know or use VS) to tell the VS project that the ui....h file depends on the .ui file, and run the necessary uic to regenerate it, so that you know you can build in VS and it will update automatically?

                EDIT Hmm, I see this is asked in https://stackoverflow.com/questions/60304171/cmake-qt5-and-autouic-not-rebuilding-when-ui-file-touched

                O Offline
                O Offline
                ollarch
                wrote on last edited by
                #7

                @JonB
                I don't kwow if it can be done automatically when the file is saved. What the Qt Visual Studio Tools do is define a custom compilation rule for *.ui files that simply calls the uic compiler and the output file goes to "GeneratedFiles" folder where the solution looks for the "ui_xxx.h" file.
                If you build all the project after saving the UI file, then you will have the access to the new added (or name changed) UI elements as it compiles the UI file. Just right clicking the UI file and compiling the UI file is what I do to avoid full project compilation that is slower than compiling only one file.

                I will take a look at the post.

                1 Reply Last reply
                1
                • A Offline
                  A Offline
                  Asphodelus
                  wrote on last edited by
                  #8

                  Thanks all!

                  I've resolve it by do a "rescan solution" for update Interlisence and it work!

                  I'm looking for a better way for do this because it's not pratical... (if someone have idea! :) )

                  1 Reply Last reply
                  0

                  • Login

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