QT with Visual Studio
-
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...)
Any idea?Thanks in advance :)
Julien -
@Asphodelus Take a look at https://doc.qt.io/archives/vs-addin/index.html
-
This post is deleted!
-
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
-
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.
-
@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 theui....h
file depends on the.ui
file, and run the necessaryuic
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
-
@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.
-
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! :) )