#include "mainwindow.h"#include "ui_mainwindow.h"MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow){ ui->setupUi(this); ui->filesView->setModel(&files); ui->streamsView->setModel(&streams); connect(ui->addFileButton, SIGNAL(released()), this, SLOT(addFile())); connect(ui->deleteFileButton, SIGNAL(released()), this, SLOT(deleteFile())); //App::addFile(QString::fromUtf8("/home/alex/28")); //filesView выводит файл}void MainWindow::addFile(){ //App::addFile(QString::fromUtf8("/home/alex/Видео/28")); //filesView ничего не делает}
#include "fileslistmodel.h"FilesListModel::FilesListModel(QObject *parent) : QAbstractListModel(parent){}int FilesListModel::rowCount(const QModelIndex &parent) const{ return App::files.count();}QVariant FilesListModel::data(const QModelIndex &index, int role) const{ if (!index.isValid()) return QVariant(); if (role == Qt::DisplayRole) return App::files[index.row()]; return QVariant();}
void MainWindow::addFile(){ App::addFile(QString::fromUtf8("/home/alex/Видео/28.mkv")); ui->filesView->reset();}