I'm trying to implement the functionality detailed in this image, but I'm running into some trouble because it seems that tree widget items don't support this kind of content:
As you can see, I would like to be able to add dynamic content underneath a tree widget item...content such as radio buttons and sliders. Any leads?
You could use item delegates to implement such items properly. But I think QTreeWidget is an overkill. You should use something like QToolBox.
Related
I'm using a custom Button class that implements the effect seen in Android Material Design. I got this from here.
I would like to implement the same thing but in the MenuBar with MenuItem, but in this class I can't override createDefaultSkin(). Is there any other way to create this dynamic background? I have searched and only found how to change the background color or how to make animated transitions of colors but nothing like setting a custom shape like a Circle in this case that it's latter animated.
MenuItems are not controls, so they are not skinnable using the controls architecture methods like createDefaultSkin() - which you have already discovered. You do have a few options though.
JavaFX supplies a CustomMenuItem class which provides a configurable node content property. So you can customize the menu items by creating CustomMenuItem instances.
Standard menu items can also be customized by setting a graphic on them.
Menu items can also be customized quite extensively without Java code by manipulating their CSS, though it would not be possible to achieve the animated effects in the android material design button you refer to.
MenuBars are controls and have a skin implementation, so you provide your own skin implementation for the entire menu bar (in the same way that the link you provided supplies a custom skin implementation for buttons). The custom menu bar skin is then responsible for rendering the GUI of the entire menu and can do so using whatever implementation you decide to provide.
A menu bar is a far more complicated control than a button, so providing a custom menu bar skin is a non-trivial task. To understand the built-in MenuBarSkin implementation, you can search the JavaFX source repository for the MenuBarSkin class. The built-in menu bar can is complicated because it has the ability to use system menu features on a Mac, pop-up menus, scene graph node based menus within an app window, etc. The built-in implementation handles some of the UI functionality for the menu bar itself and in other cases delegates to grabbing custom node content from menu items, various Java helper classes and ultimately the underlying OS windowing toolkit support for menu display and management.
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.
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.
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.
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.