pySide/ pyQt - Marker bar? - qt

What would be the easiest way to create a marker bar in PySide/ PyQt, similar to
(source: sideofsoftware.com)
?

There is a QScrollBar class. You can subclass it and override the paintEvent method to do custom painting. Any class that inherits from QAbstractScrollArea (e.g. QScrollArea, QTextEdit, etc.) has two methods to set the scrollbar for the vertical or horizontal scrollbar (e.g. setVerticalScrollbar()). So create your own scrollbar class and then use those methods to apply it to the widgets that can use it.

Related

How to make a layout invisible in Qt?

I add a layout in a dialog and sometimes I want it and all its containing widgets to hide. How to implement it? I try layout->setEnable(false), but it doesn't seem to work in my tests.
You can't do that. You should add a widget in your form, put children inside the widget and assign desired layout to the widget. The behavior will be generally the same, but you can use setVisible or hide methods of the widget.
Transform QLayout to QWidget first, then you can use QWidget->hide().

How to draw a header in my own widget in Qt?

Does anyone know how to draw a header (and other simple elements), just like in, for example, QTreeWidget, in my own widget?
I would like to use style and call something like:
drawElement(CE_Header, rect, painter);
to draw standard header in specified rect.
QStyle::drawControl can't do it, because it draws control over whole widget.
Qt documentation doesn't say much about it.
Subclass QHeaderView and reimplement the paint method, inside there you can use the QStyleOption data. Then use QTreeWidget::setHeader(QHeaderView* header) to set your header in the widget.

Resizing a QDialog after adding components to a child widget

I'm a bit new to QT but have to work on existing code. Here's the case:
I have a class extending QDialog. the constructor sets a QGridLayout then adding three other widgets to it. One of the widgets is a QScrollArea containing a QGroupBox. this QGroupBox has a QVBoxLayout and there I'm adding a list of widgets at runtime. The size of the scroll area should grow until a given limit is reached before showing the scrollbars so that they are only used when the dialog would grow too high. I've found that the sizeHint of the outer layout doesn't update when the sizeHint of the scroll area updates. How can I refresh this, or is there a better way to resize the parent dialog?
What about using widgetResizable property of QScrollArea? It should try to resize view to avoid using scorllbars.

java equivalent panels in qt

I would like to know the Java panel equivalent in QT. I mean which class do we need to use in QT, i.e. qframe or qwidget. I need to add many panels to my QT mainwindow.
QFrame, QScrollArea, etc. have properties that handle panel appearance and are suitable for component containers and form layout.
QWidget has no frameShape(), frameShadow(), or lineWidth(), but it has layout and size operation methods, so it can also be used as a panel if you do not need borders, scroll, docking or other additional behavior.

How to add menu to a widget derived from Qwidget

i want to know how to add menu to a widget, which is derived from Qwidget in QT symbian,
i know how to add menu to window derived from Qwindow, but i am not getting for widget
derived from Qwidget
pls help me..
Thanks
QMainWindow provides you convenience function to add and manage a QMenuBar.
With a window that inherits from QWidget (instead of QMainWindow) you need to achieve this by yourself. You can add the menu bar in the window layout like any other QWidget using the function add. By playing with the layouts you can place QMenuBar at the top of the window.
An other way can be to use a QToolBar.

Resources