I want to use Qt to build a GUI with a central widget like the visual studio. The widget has a number of tabbed windows to edit h/cpp files. Which widget should I use?
You can create only something similar to Visual Studio using Qt classes. Central widget should also have layout. Only QMainWindow has setCentralWidget method.
QTextEdit with QSyntaxHighlighter to make your text with color.
QMenu requires also QAction. You can also use QToolBar
QSplitter allows you to move(resize widgets)
QLineEdit for small texts (for example search word or something else)
Description:
I think the closest thing you can find to replicate the visual studio tabbed windows is QMdiArea. But if you want the full functionality of Visual Studio's tabbed widgets you need to implement your own widget.
I run into the same problem and found a library that adds the ability to use similar layouts as VS do: dynamically resizable, stackable (horizontally, vertically, on each other), undockable, closable, saveable.
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System
It has its own issues (at least on Linux), but it's a good point to start, anyway.
Related
I'm using Qt 4.8 to build an application, and am finding the default docking support in Qt to be quite restrictive for my purposes. Does anyone have any experience customizing the Qt docking behavior?
Instead of being constrained to the four dock widget areas, I would like to extend the docking capability to work similar to Photoshop/Flash or even Visual Studio - where any edge of the main window or another panel can be used for panel layout? From what I can tell, I am forced to re-implement QMainWindow to add my own logic. Is this assessment correct?
I have tried to search on the internet and here as well, without success though. I am using Qt 4.8.2 and design my app in the Designer, then I write code in VS2010. I would like to show a chart on the application window, e.g. like http://www.infocaptor.com/user_help/help_img/dashboard_line_chart_screen.png , based on some data that are created by the app.
In the Widget Box of the Designer, I can't find any widget related to drawing. So I tried creating a QTextEdit and drawing on that using QPainter. However, this does not work. I can draw on the whole appwindow, but not just on the text edit. So the question is: what widget can be added onto the app window in the designer and that is going to allow me to draw on it using QPainter?
I'm eluded as the documentation says specifically that QPainter can draw on any QWidget which a QTextEdit is...
Any help is much appreciated,
Daniel
The function of "drawing" is tooo complex/unspecific to be included as a specialized widget. You'll have to create it yourself and implement the desired drawing functions.
Here is an example which you can learn from, the scribblearea class could be pretty much what you are looking for. In that case you can copy it to your project and use in in the Qt-Designer by promoting a widget to this class.
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.
I'd like to implement a sidepanel in my Qt window. I search something like the one that is used in the Visual Studio (see below).
Important notes:
The widgets don't have to be moveable
resizing should be possible
each widget should be clearly separated from the other layout
Does anyone have an idea how I could build such a sidepanel? (Maybe there even exists a library)
Or does anyone know a project which uses Qt and some kind of sidepanel?
One option would be to use QDockWidgets. That's the type of thing they are intended for inside a QMainWindow.
You can put toolbars, QTreeViews and QTableViews (or related) widgets inside your dock widget to simulate the screenshot you posted.
For an example usage: Dock Widgets Example.
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)