[Interest] dynamic widget creation in QScrollArea
Reto Tschofenig, ODT Informatik GmbH
qt.ml at odt.ch
Thu Aug 4 15:09:11 CEST 2016
Hi Frank
if the children are the same type and it's like a table, I would
recommend the following alternative:
don't inherit from it QScrollArea but instantiate as many child widget's
as visible. bind now the child-widgets depending of the position of the
scrollbar with the object.
> widgets horizontally
my example is vertical, but you could adapt it...
+- ListView ------------------------------------+
| +- Viewport ----------------------------+ +-+ |
| | +- 1. ItemView ---------------------+ | |s| |
| | + Edit Label or whatever | | |c| |
| | +-----------------------------------+ | |r| |
| | +- 2. ItemView ---------------------+ | |o| |
| | + Edit Label or whatever | | |l| |
| | +-----------------------------------+ | |l| |
| | +- 3. ItemView ---------------------+ | |b| |
| | + Edit Label or whatever | | |a| |
| | +-----------------------------------+ | |r| |
| | +- 4. ItemView ---------------------+ | | | |
| | + Edit Label or whatever | | | | |
| | +-----------------------------------+ | | | |
| +---------------------------------------+ +-+ |
+-----------------------------------------------+
class ListView : QWidget{
QWidget* _viewport; // the parent for the ItemView's
QScrollBar* _scrollbar;
QList<ItemView*> _items;
int _scrollPosition;
QList<Object*> _objects;
}
class ItemView : QWidget{
Object* _object;
QLineEdit* _someEdits;
void bind( Object* object );
}
> smooth vertical scrolling
Of course, the child-widgets could be also pixel accuracy moved.
> QListView in icon mode
replace the QLineEdit with a Icon-Widget or Label or paint it in
ItemView directly.
good luck
Reto
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160804/5336f7ee/attachment.html>
More information about the Interest
mailing list