Hi,
I want to write a program who read in all file names out of one folder and after this print out files of a special typ(mp3´s).
my current code:
void MainWindow::on_Weiter_clicked()
{
QWidget newWindow;
newWindow.resize(600,500);
std::cout <<"new window muesste erstellt sein"<<std::endl;//Überprüfung ab wann es nichtmehr funktioniert
QVBoxLayout *vbl = new QVBoxLayout(&newWindow);
QDir directory (sPath);
QStringList Filter;
Filter<< "*.mp3";
QStringList Liste = directory.entryList(Filter);
QStringList::const_iterator titel;
std::cout <<"Liste im string"<<std::endl;//wieder überprüfung ab wann es nichtmehr funktioniert
for(titel=Liste.constBegin(); titel!=Liste.constEnd(); ++titel)
{
std::cout <<(*titel).toLatin1().constData()<<std::endl;// das wird nichtmehr ausgegeben
int z=0;
QLabel label ((*titel).toLatin1().constData(),&newWindow);
vbl->addWidget(&label);
newWindow.show();
z++;
std::cout <<"ende der for schleife"<<std::endl;
}
}
The “int z” should be the beginning of dynamic label objects (I don’t know how many files I have to display) but I don’t know how to make them.
My biggest problem is that the “newWindow” is created but not displayed(it is a problem with the “for” but I don’t know what I have to change)
Until the “ std::cout <<“Liste im string”<<std::endl; “ the program print out my check text´s but every check text in the “for” isn’t printed out. The “sPath” is a QString what gets the Path from a file system model.
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QString sPath ="C:\";
dirmodel = new QFileSystemModel(this);
dirmodel->setFilter(QDir::NoDotAndDotDot | QDir::AllDirs);
dirmodel ->setRootPath(sPath);
ui->treeView->setModel(dirmodel);
std::cout <<"Window erstellen tut"<<std::endl;//zur Überprüfung
}
void MainWindow::on_treeView_clicked(const QModelIndex &index)
{
QString sPath=dirmodel->fileInfo(index).absoluteFilePath();
}
Can someone help me?
P.s. Sorry for my bad English.
↧