Paul Bae
Paul Bae

Reputation: 60

QListViewModel UI

I'm trying to write a QListView model and link it to my main UI (from Qt Designer)

here's my main function:

#include "notepad.h"
#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    Notepad w;
    w.show();

    return a.exec();
}

and here's my main class Notepad:

Notepad::Notepad(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::Notepad)
{
/* some other setup code */
ui->setupUi(this);

FileViewModel fileModel(files, 0);
ui->listView->setModel(&fileModel);
ui->listView->show();
}

However, the listView doesn't seem to be displaying any elements, whereas I've provided basic functionality in my model.

Any ideas or suggestions?

Upvotes: 0

Views: 98

Answers (1)

Jablonski
Jablonski

Reputation: 18524

Try this:

FileViewModel *fileModel = new FileViewModel(files, 0);
ui->listView->setModel(fileModel);

Upvotes: 1

Related Questions