Edit multiple QT widgets (GUI) in QT Creator - qt

I have a general GUI editing question using QT. We can create GUI applications using the QT form view where we can edit the layout graphically. And then we can swtich to the code to fine tune. Problem is i can Edit only the main window GUI. Now if i want to create another dialog e.g, pop up, i could only do so from code. Can you recommend any example or direct to the QT Documentation which shows how to edit multiple widget/dialog windows graphically using IDE.
I looked through the questions asked here which neatly explains how to open a new dialog window with code examples. But i could not find any example showing how to edit multiple layouts using QT's graphical editor.

To add other forms to your application, right click on the project name in the project tree view, then select "Add New", then under the Qt category look for "Qt Designer Form Class", like in this picture:
Follow the rest of the wizard (will ask the class name) and in the end you should find tree more files in your treeview with extensions .h, .cpp and a .ui. Click on the latter one to open the designer and edit the form from there.

Related

Need to write Extension for Code Maps of a solution

I want to write an extension on dgml file. Code map of Solution in visual studio.
How do I plug-in my code on a context menu of links shown in the diagram
I'm uncertain if there are any extensibility points build into the dgml editor, but you can certainly add menu items to the "Architecture" drop down menu item with a VS extension built with the Visual Studio SDK.
You'll want to read up on developing Visual Studio extensions, so that you are familiar with how menu items (also referred to as commands) are added to the VS IDE. Also, there are two categories of windows you can display in Visual Studio. Tool Windows, and Document Winodws. You'll need to figure out which type fits your particular requirements. Generally speaking if your underlying data is stored in a file, you'll most likely want to implement a document window (also known as a custom editor or designer). For example, the window displayed after selecting "Generate Code Map for solution" is a custom designer for .DGML files.
Below are a few links to get you pointed in the right direction.
Visual Studio SDK
Create an extension with a menu command
Create an extension with a tool window
Walkthrough: Create a custom editor
VSSDK Extensibility Samples (github)
Sincerely,

Complex UI with MVC

I'm trying to recreate a text editor I've made but using the MVC design pattern; I'm not totally sure about certain parts of it.
For example, I have a tree view displaying my project directory, and a text editor showing the contents of a file, along with this i have output from compilation of files being displayed as well as a tabbed interface.
Would this be split into a few different models or under one big model? If it's under 1 big model how would I go about using the Qt model classes for such a thing?
Open up Qt Designer and drag and drop all the stuff you need. It should get you pretty far.
I think the only model/view you should worry about is the QFileSystemModel and pairing it up with a QTreeView. Everything else Qt has some nice examples showing how to do it.
If you are showing multiple files at once in separate tabs, then you might want to look into the Tabbed Browser Example to see how its done.
http://doc.qt.io/qt-5/examples-mainwindow.html
http://doc.qt.io/qt-5/qtwidgets-richtext-syntaxhighlighter-example.html
http://doc.qt.io/qt-5/qtwidgets-widgets-codeeditor-example.html
http://doc.qt.io/qt-5/qtwebkitexamples-webkitwidgets-browser-example.html
I like QDockWidgets and using QActions and putting them on the QToolbar in a QMainWindow.
http://doc.qt.io/qt-5/model-view-programming.html
http://doc.qt.io/qt-5/qfilesystemmodel.html#details
http://doc.qt.io/qt-5/qmdiarea.html#details
http://doc.qt.io/qt-5/qtextedit.html
For the compilation part you will just need to create a QProcess and connect its output to a QTextEdit.
Hope that helps.

QML and Qt Creator

I designed a Qt application by Qt creator. As you well know when you build a new form is possible to drag an drop the default items inside the main window. Instead of use classical "push button" I created a custom button by adding .qml file to the project. The problem now is that I don't know how I can use (or integrate) the new button inside the form of my project.
Thanks in advance
As long as your component is in the path of your application qml files, all you need to use your component is to place it somewhere. You don't need to include or import anything. Any user component is directly available to the entire project.
As long as the QML component is made from only built in components, it can even be safely loaded from arbitrary location on disk, over network or just from a source string. Check this answer for details on dynamic instantiation.
A friendly advice - type the code, do not use the visual editor - it is pretty weak.
EDIT: I don't know about you, but for me, seems like every custom qml file in the project qml folder is automatically added to the QML types in the designer library. So contrary to what I assumed, you shouldn't really need to do anything to get your custom type available for use in the designer.
I found this 1 year-old question when facing the same problem. This is what I found out:
If you save your custom button with an initial uppercase letter (CustomButton.qml instead of customButtom.qml), QtDesigner shows your component in the library panel correctly.
Sometimes you need to restart QtDesigner to work.

Adding user built widgets to a ui file in qt creator

The qt designer portion of qt creator has many built in widgets. But let's say I want to add custom widgets created in the same qt project to the ui file of the window. By taking these steps:
Create a new Qt GUI application with a main window, we'll call the window A.
Add a new widget to the project, the widget just uses standard UI components, say buttons. We'll call this widget B.
Add an instance of widget B to window A.
Now, I know one way to do that, and that is:
In window A, add a blank widget (or widget container, from the containers section of the list of possible widgets. We'll call this widget C.
Promote it (widget C) to widget B.
However, the problem with this is that Qt Creator's designer treats it like a generic QWidget. And as such, you can't do things like add it to a splitter, or connect signals/slots that are specific to the widget.
So is there any other ways to add widget B to window A in the ui file using qt creator? Thank you.
I'm not sure to understood your question well so I could ask the wrong question. Are you sure your "B" widget is a subclass of QDesignerCustomWidgetInterface? This should expose all stuff that your widget/plugin offers...
Last note: a friend of mine tried to add a custom widget like you. And at the end of the described procedure that Lol4t0 told you, he found you must compile plugin with the same compiler with wich qtcreator/designer was compiled. This happens because as we know c++ doesn't keep ABI compability (instead of i.e. C language) stuff like: Name handling can change from compiler to compiler, how data is loaded into registers can change...and so on. My friend tried to compile plugin with mingw, but he found that qtcreator was compiled with visual studio compiler. Therefore if you want to deploy your plugin on Windows or you compile your plugin with visual studio, or you have to compile qtcreator/designer from scratch.
I know this is a very old question, and I'm not sure what capabilities Designer had in 2012, but I came across this in a Google search for something else and figured I'd add some missing info:
However, the problem with this is that Qt Creator's designer treats it like a generic QWidget. And as such, you can't do things like add it to a splitter, or connect signals/slots that are specific to the widget.
Generic QWidgets can be added to splitters with no issues these days.
As far as signals and slots go, you can use them like so:
After promoting a widget to your custom widget, right-click it and choose "Change signals/slots..." from the context menu.
Add the signatures for any custom signals and slots you want to be able to use in Designer / Creator here.
Now those signals and slots will be accessible in Designer like any other signals and slots.
The only thing you can't really get with promoted widgets is access to custom properties in the property panel; for that, yeah, you'll need to go through the custom widget creation process.

Workflow in QtDesigner

I'm using Qt 2009.03 with the Visual Studio addon 1.0.2. I'm writing an application that has commands to open non-modal windows, and multiple windows can be opened at the same time.
These windows themselves need to be designed in QtDesigner. An example of what I'm looking for can be found in Firefox. If I go to Tools / Addons it opens a child window.
I'm not sure what is the correct workflow in QtDesigner. I thought it might be a "Frame" but that doesn't seem to be a window, with your standard close / minimize tabs and menu bar. I thought perhaps it was (from Visual Studio) File / New Project / Qt4 Projects / Qt4 Designer plugin. That generates some classes, but there's no .ui file for me to design with.
In Visual Studio, the workflow I use when I want to design a new window is to add a Qt GUI class with Project->Add Class...->Qt4 Classes->Qt4GuiClass.
Then, fill out the form as necessary and the VS add-in will add the appropriate ui and moc files. Double clicking on the ui file will bring up Qt Designer, which you can use to lay your window out.
Consider restating the question, I'm not sure I understood what the problem is -- how to create a ui file? How to create ui file inside VS? (or Creator?) What Qt class to base your window on? Something else?
Do you use QtCreator or VS with Qt integration? (Or is there hybrid approach? O_o)
Anyway, you can always open QtDesigner separately and create ui file inside. Then add it to .pro file (assuming you are using .pro and not VS solution directly).
For base window you can even use QWidget. Decorations (titlebar, system menu, minimize, etc) depend on window flags passed into constructor.
Taking your example:
the Firefox main window is a QMainWindow
the addin window is a QDialog (non-modal)
You create a Qt designer UI (VS 2003) by right clicking your project in the solution explorer, clicking "Add" and selecting "Add Qt GUI class".
Usually you use a QMainWindow for the main window in your application. This will give you your minimise, and close buttons. In your QMainWindow you can add or remove a menu bar by right clicking on the form in QtDesigner.
For a non-model window, you would normally use a QDialog. This will also give you your minimise, and close buttons.
Are you definately using the visual studio add-in (opens ui files in Qt Designer)?
There is also the visual studio integration. (opens ui files within visual studio and provides tools to edit it)

Resources