Listing with custom widget
-
I'm new to Qt and I'm trying to create a software that is going to have a listing, like a list of things. I'm going to give you some images of softwares that does that:
You see the listing that is with some icons, the title, the progressbae and stuff.
I was wondering how to create this and how to handle each one of them, for example, if I'm downloading one of them I can set the progress for that item?
-
Is there any tutorial where I can read or watch about that or creating something similar to that?
-
Hi
the
http://doc.qt.io/qt-5/qtnetwork-torrent-example.html
has mainwindow.cpp
class TorrentViewDelegate : public QItemDelegateWhich is the same just with the older class
"Note that QStyledItemDelegate has taken over the job of drawing Qt's item views. We recommend the use of QStyledItemDelegate when creating new delegates."It just draws a progressbar with QStyleOptionProgressBar
but you just need to draw other stuff you want.This is the correct way and have good performance with many list items.
Can i ask how many items you will have?
-
@mrjj said in Listing with custom widget:
many
I don't have yet but I'm planing in having only two or three icon, a title, a button, a progress bar.
-
@yugosonegi
Ok, should not be that much extra code to draw.
Note that the sample only draws the things.
To make it active, like the button, you must also implement editing feature
that shows a real button so its clickable,
This sampel show an active one
http://doc.qt.io/qt-5/qtwidgets-itemviews-stardelegate-example.html
The
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
const QModelIndex &index) const override;
is key here. It will allow you to create a real button/widget and not a picture of it
for the current /selected item/row and hence you can click it etc.