Show a download list with qt4 - c++

What is the best way to show a list of downloads using QT4?
1 QListWidget
2 QTreeWidget
3 QTableWidget
Thanks

It depends on how much functionality you want. If you just want to simply list the filenames, use a QListWidget. If you want to list other things like progress, filesize, etc. then you may want to use a QTableWidget. If you want to be able to group downloads under different categories, you can use the QTreeWidget, which will also allow for multiple table cells per row like the QTableWidget.
If you want something fancier like the firefox downloader, you may have to create an item delegate to handle the drawing yourself.

Use the model-view-controller widgets.
QListView
QTableView
QTreeView

Related

Qt: List of (custom) QWidgets without performance problems

I'm right now creating an Qt-application and have following problem:
I designed a custom QWidget with some labels and checkboxes. The application should now show a list of the custom QWidgets. I tried the QListWidget but is very slow for my use case. I want to add over 6000 elements of my custom QWidget. If I create these instances of the element and add it to the QListWidget the application will crashed.
Which is the best approach for my issue?
Thanks a lot!
As others have noted, QListWidget or QListView is the way to go. Also note that you should not display custom widgets with it, try using a custom QStyledItemDelegate instead and draw the items yourself. Depending on what you need, this can get complex really fast. I have used QTableView with this approach with tenth of thousands of items without performance problems.
If you really need to display custom widgets, check out a library I wrote some time ago for that exact purpose: longscroll-qt
.

Is there a nice way to map a QStandardItemModel to many QLineEdits

I have a single value that needs to appear on several parts of my UI.
Where I have a list of values that is duplicated - for instance QComboboxes, I create a single QStandardItemModel and set that model on the combos.
I'd like to do something similar for this single value. Great, I thought, I'll use QDataWidgetMapper, but it turns out that QDataWidgetMapper doesn't allow one to many mappings, i.e. I can only map one widget to each column in my table. I'd like to map many.
I can think of a few roll-my-own ways around this but if there's an easy way to do it that is built in, I'd appreciate hearing it. I'm on Qt 4.7 fwiw.
You could create a QDataWidgetMapper for each widget.
Alternatively, make one widget be the 'master value' and connect its valueChanged() signal (or whatever you want to call it) to the corresponding setValue() slot of all the 'slave' widgets.

Creating a List of QPushButtons

I'd like to create a list of QPushButtons that are added and removed at runtime. I figure that an item view widget would accomplish this (QListWidget). The reason for wanting to use an item view instead of a layout is that I would like to scroll through a list of buttons instead of just trying make them all fit. However, I don't see too many examples of QListWidgets being used to store a QPushButtons.
I'd like some tips, pointers, or examples.
I think you should not use QListWidget in this case. Create a widget with a layout and all your buttons. Then put in QScrollArea.
You can add widgets to QListWidget using its setIndexWidget function.

SpinBoxDelegate and QItemDelegate

I work on project It's like SpinBoxDelegate in Qt sample project but I must customize It, I mean having different widget(textbox) in second and third column of table view instead of spainBox.What do you suggest?
Try instead tableView.setItemDelegate(&delegate); from the example something like QTableView::setItemDelegateForColumn().
Plus have a look at this one tutor.
If you can use a QTableWidget instead of a QTableView you can use QTableWidget.setCellWidget() to put another widget inside a cell. For instance, you could put your own QLineEdit or QSpinBox in the cell.
Unfortunately, if you have to display too many of these it will cause performance issues.

customlist in Qt

I want to create a Custom List which will contain not only a single line text but a combination of text, images buttons, progressbars. Is there any way to do this? I am unable to create that.
Please help me.
You can try to use QTableWidget where you can display a widget in a cell.
In your case you can do this:
Create a custom widget with buttons, progress bar, etc.
Implement a QTableView with only one column
Insert an instantiate custom widget in each row you are using
This should do what you want to achieve