Disabled splitter in qt designer - qt

I'm using qt 4.8.0 on windows 7.
When I open qt designer and create widget in it, I cannot set 'Lay Out in a vertical/horizontal in Splitter'. Also there is no Splitter in a Layouts widget box.
All other layouts are working well.
Have anyone run into same or similar problem?

You need to select two or more widgets and then use the layout -> vertical/horizontal splitter option. This will give designer enough context to be able to perform the operation.
Also note that the selected widgets cannot be part of a layout already. If they are, you need to break the layout first (layout->Break Layout in context menu).

It's in the contextual menu that appears on right-click in the body of the widget.
You can establish the widget's layout including splitter there.
EDIT: Sorry, I misunderstood in a rapid first-reading. Are you saying it doesn't appear in the right-click menu, between the other layout options?

Related

How can I use QMenuBar to switch between widgets?

I don't know much about QT. I am trying to do my first GUI and actually this is the first thing that I want to do.
How can I set up top menu bar to switch between layouts? Again, I don't know yet how to even set up these layouts and I don't know the jargon to name the things theirs names, but I'll get to it.. I hope.
Actually, Windows has this type of windows all over the system. Can I make one of these myself?
Qt has a QtabWidget that has its own layout on every tab, so you dont need to define anything, qt handle t runtime the display of the layout associated to every tab

Layout required in designer but not in hand coded app?

I'm new to Qt and it's quite a learning curve!
I've been search/reading/hacking and learning for most of the day on this one.
I'm working on an app that will have a image in a scroll area as it's main purpose. The image viewer example is where I started. This example appears to be "laid out by hand" if you will - i.e. there are no .ui form files for it (it's trivial so why not).
So here is the rub - I want to use designer to build a much more sophisticated app. If I start fresh with a new project and use designer the resizing doesn't work unless I add layout (used vertical, all appear to fix the resize issue) to the .ui form.
Designer creates a lot more code to do the same thing - I don't care, it is after all an IDE / code generation tool.
However it's not clear to me why the layout is required when I use designer and not if I code it by hand. I searched the code for the image viewer example and there doesn't seem to be ANY layout involved at all, just 3 or 4 nested widgits (Main/Scroll/Label).
Is the default layout basically built in?
The example you linked to uses a QMainWindow. This widget has its own layout because it has built-in support for menubars, toolbars, dock widgets and a statusbar:
Main Window Framework:
Normally, the widget set as the central-widget would need to have a layout explicitly set on it in order to layout its own child widgets. However, in your linked example, the central-widget is a QScrollArea, which also happens to have a built-in layout. This is all just coincidental, though. The large majority of widgets don't have a built-in layout, so most GUIs will need to explictly add at least one layout, and several will usually be needed for more complex applications.
I would say Qt Designer is absolutely essential when it comes to experimenting with layouts (especially when you start learning Qt). Even if you don't actually use the ui file, it's still very helpful to just view the code that would be generated from it.

How can I create a system similar to QDockWidget but for tabs?

I had an idea I have no clue on how to implement. I'm working with Qt and I'ld like to have a system of tabs that allows me to use tabs in the same way one can use QDockWidgets, that is: with QDockWidgets one can pick a widget and use it floating around the monitor or he can dock it in a QMainWindow in any of the four sides. Well I would like to have such attribute with a QTabWidget! So suppose I have two QTabWidgets in front of me. With the proposed idea, I would be capable to drag and drop a tab (with its widget) from one QTabWidget to another or even simply undock it from its original QTabWidget and start using it independently as another QTabWidget with one tab.
Well I couldn't find a way to use QTabWidget this way "naturally"; it seems Qt doesn't provide such possibility with its pack of widget classes. So does anybody knows any project open to the public containing a class able to do such thing? Or how could I implement such a new class myself? (I don't know for example how could I make the drag and drop effect from a QTabBar since even if setMovable is set to true, still isn't possible to make the tab go away from area of the QTabBar.
Any help will be appreciated.
QDockWidgets already provide possibility to be tabbed.
You can check Dock Widgets Qt sample project in Main Windows section.
Screen of the just launched sample app:
Screen of the tabbed doc widgets:
Check this answer for implementation details.

Which widget is used in Visual Studio's central widget?

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.

Sidepanel with Qt

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.

Resources