Unsolved Several small dockable windows or widgets
-
Hi,
I would like to display some small windows or widgets with Qt. Each should stand as a "notepad" for a configured item.
They should be dynamically generated, and also be erasable by the user at any time. I have attached a picture, as I imagine. Unfortunately, I'm not really sure how to do that with Qt.
Best regards,
TinTin
-
Hi,
You can use a QScrollArea. Put a QVBoxLayout on the widget you will set on the area. Then you can the widgets you want in there.
-
Hi SGaist,
Thanks for the support.
The widget itself I'm not sure if I should derive from QWidget, or from QFrame.
When I am at a QWidget
setStyleSheet ("border: 3px solid rgb (" 1,1,1 "))
put, I get boxes for the two labels that I have in my widget, but no box around the entire widget. When I derive from a QFrame, I get all three edges. But I would really only interested in the outside. How can I implement that cleverly?
-
@TinTin82 said in Several small dockable windows or widgets:
The widget itself I'm not sure if I should derive from QWidget, or from QFrame.
QFrame itself also inherits QWidget.
It depends how your "notepad"-widgets should look like and what functions they need to provide (Buttons, Events etc.).
You used the keyword "dockable" :) Have you had a look at QDockWidgets already?
Then, the right side of your main window would be the docking area. You can (un-)dock or close your notepads and move them around.EDIT:
Your border-problem has to do with stylesheet. If you set
border: 3px....[...]
as style to your widget without any other specification, all childs and inheriting objects also get this style. This explains the behavior shown above in your comment.To set your border only around the parent widget and not around your "Rectangle" / "Edit" labels, you have to set a class / object in your stylesheet, like this:
QString style("QWidget#YourWidgetObjName{ border: 3px solid rgb(%1,%2,%3)}").arg(QString::number(rgb[0])).arg(QString::number(rgb[1])).arg(QString::number(rgb[2])); setStyleSheet(style);