How can I make two rows of tabs in Qt - qt

I would like to have something like the following image. I want two rows of tabs. One is included in the other. Is using two QTabWidget the way to go? Also, I would like to mention that the program's main window will display this structure. If you have any suggestions...
I would like the tabs to look like the following (of course, not exactly; this handmade image is awful).
Image http://imageshack.us/a/img831/3889/subtabs.png

Use nested QTabWidgets: an outer primary tab which contains its own secondary QTabWidget (where one is necessary).
Since you are after specific look, then there are three possible solutions (ordered by complexity) :
See what you can do with Qt style sheets using nested QTabWidgets. See this answer for some example code, and of course reference in docs.
Forget QTabWidget, write your own, containing custom tab bar, and using a QStackedWidget or just nested QStackedLayout for tab contents. You can nest these custom tabbed widgets like you would with QTabWidget, or just have dynamic two-row
tab bar in one non-nested custom tab widget, it's your code now.
Start using QML for UI, perhaps just for a custom tab bar, perhaps for the whole central widget, depending on what you have there.

You can use QTabBar instead. A QTabWidget is formed from a QStackedWidget and a QTabBar, but you can use QTabBars directly - and have two or three or more layers of tabs.

Related

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.

Select layout by user in QML application

In my QML application there are many components like map, video, console and so on. I want to allow the user to change current layout of components (position and visibility). The problem is that I want each layout to be separate .qml file which reuse already existing components. For example on layout switch map should not be destroyed and instantiated again. Here is an example of what I would like to avoid - each layout creates components only for themselves so layout cannot be changed. I had some experiments with reparenting components on state change but it produces a lot of code and nothing works.
Looks like you need to use states! Each state can arrange same items in different layout. They can even re-parent items.
Now question is: can you move state description to separate file. IMO it should work. I didn't try it.
Anyway items will not be recreated so you will achieve main goal.

Adding custom widgets to QStackedWidget

I'm having difficulty adding a custom widget to a QStackedWidget. I want to include a widget with a different grid layout in this stacked widget.
If someone could show me how to set up the layout (buttons, etc.) inside the stacked widget, that would be even better. The main dialog containing the stacked widget is really simple, and I don't want to clutter it up with tonnes of grid just for one widget inside the stacked widget.
At the moment I'm trying to make the complex widget as a seperate class and insert an instance of this class into the stacked widget using .addWidget() (this doesn't work).
Maybe I'm thinking about it the wrong way?
I'm using PyQt, but C++ answers are acceptable — I can get an idea of how things work by looking at C++ (well, I've been fine so far =s).
If you're using QtCreator I suggest do it this way:
Design each page/widget as a seperate class (seperate *.cpp, *.h and *.ui files) - press ctrl+n and choose Qt / Qt designer form class.
Add X pages/widgets to the stackedWidget. X is the number of views You created
Promote each widget to be your custom designed page (right click in the objects tree on the right and choose promote widget). In field "promoted class name enter" enter the name of your cutom creacted page.
This should get you starded. I hope it solves Your problem. Ofcourse You have to design each view.

Create drag-able panels in Flex like its in netvibes.com

I want to create a news application for my website.
My question is how should i create drag-able panels/canvas inside another panel/canvas.
What i exactly intend to do can be seen on netvibes.com . The website has different panels of every news group, and this panel could be moved from one place to other, but in a well defined manner. And the other panel take over the place of dragged panel.
Is there any component in flex, which can help me make something like that.
If i was unable to make my question clear, plz let me know, i will try to make it more clear.
Regards
Zeeshan
A TileList with drag and drop enabled should be able to accomplish something like that. Or, use a Spark List with a custom layout that you create.
It might be a bit tricky getting the list elements to drag and drop based on clicking the title, but it should be doable.
I think you should consider a more advanced solution with drap-n-drop with a custom panel based component. The places the panels can move can be implemented with a different custom canvas based component. The advantage would be to move the components into different custom positions and panels can be resized independent of each other.
Adobe has some good tutorials for drag-drop operations.

Classes to use for a flexible image selection/tagging widget in Qt

I'm new with Qt and am looking for advice on how to structure this.
I want a flexible widget that can display a set of images (normally read from a directory but other sources too) and let the user select images with the arrow keys and/or mouse and also apply custom tags.
For example there might be 5 tags defined by the application. A user can press a key to select one, and then a little icon would appear in or near the image preview showing that it was selected for that tag.
Would I need to implement this from scratch via drawing on a QWidget or is there something that would make a sensible base class? Thanks!
I would use a QListView base class, and then subclass QStyledItemDelegate.
There is an example here which might help you.

Resources