Tell me what widgets in Qt can create something like a list of recommended videos on youtube.com. This will be a playlist, in which the user himself adds the video, when you click on a specific, it will play. Perhaps QListWidget, but how to add an action when you click on the video, how to determine which one is chosen, and most importantly, whether you can add a QVideoWidget there.
1 answer
Yes, QListWidget suitable for this purpose.
Most likely, you will also need a delegate, for example, QStyledItemDelegate , in which you can catch a click on a particular video icon. To do this, in the delegate class, override the editorEvent() method, something like this:
bool Delegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) { if (event->type() == QEvent::MouseButtonRelease){ if (/* в районе вашей видио иконки */) emit this->clickedVideo(index); } } How your video icon is located can be defined in the delegate’s paint() method. Or leave the default.
The clickedVideo(index) signal is connected to the slot that will play the video. The index variable will help you determine which video was clicked on.
About adding QVideoWidget , it’s not quite clear exactly where you want it. If you want the video to play directly in the QListWidget , then you need to look for how to do this in the delegate, in the paint() method.
If you want each video to be represented by an icon, but the video itself opens in the main window (or another widget), then it will be enough just to set the size of the video icons for the ListWidget :
listWidget->setIconSize(200,200); Then it remains only to connect the signals and slots to achieve the desired result. It is rather difficult to give a more detailed answer, since The question contains several questions. I advise you to read about delegates and see examples of how to use them. I hope this will help you find a solution.