In Qt Widget Application (c++), a part of my *.ui file consists of a QListView with two QTextEdits as its items like the below figure.
As you can see custom widget includes two QTextEdit that each one has its text and stylesheet. As I searched on the net, there are solutions like HtmlDelegate classes for rendering text of items on QListView. But these classes only present ONE QTextEdit as item for QListView. In future, I want sync the QListView scrol status with a QMultimedia status like Podcast apps. Does anyone have any idea?
well first of all you should create your custom widget like this:
Then you add it to your Model of QListView
by using setIndexWidget
function like this:
QStandardItemModel *model = new QStandardItemModel(120, 1);
ui->listView->setModel(model);
for (int r = 0; r < 120; r++)
{
ui->listView->setIndexWidget(model->index(r, 0), new CustomTextEdits);
}
Final Result:
you can see the source code here: