View Single Post
Posts: 3,617 | Thanked: 2,412 times | Joined on Nov 2009 @ Cambridge, UK
#7
Originally Posted by ahmadka View Post
Alright, here's the refreshFoldersList() function

Code:
void Canvas::refreshFoldersList(QString inputPath)
{
    QDir *dir = new QDir(inputPath);
    dir->setFilter(QDir::AllDirs);
    dir->setSorting(QDir::Name);

    if(dir->exists()==true)
    {
        foldersList->clear(); //problem
        foldersStringList = new QStringList(dir->entryList());
        foldersStringList->removeFirst();
        foldersStringList->removeFirst();
        foldersList->addItems(*foldersStringList); //Problem

    }
    else
    {
        printMessage("ERROR f9g87: Path doesn't exist!!");
    }

}
And here's the browseFolders() function (called first!):

Code:
void Canvas::browseFolders()
{

    QListWidget *foldersList = new QListWidget();
    foldersList->setSelectionMode(QAbstractItemView::SingleSelection);

    
    directoryUpButton = new QPushButton("Up");
    newFolderButton = new QPushButton("New");
    selectCurrentDirectoryButton = new QMaemo5ValueButton("Shams");

    refreshFoldersList("/home/user/MyDocs/"); //THE CALL IS MADE

    overallLayout = new QHBoxLayout();
    spbl = new QVBoxLayout();

    spbl->addWidget(directoryUpButton);
    spbl->addWidget(newFolderButton);
    spbl->addWidget(selectCurrentDirectoryButton);
    overallLayout->addWidget(foldersList);
    overallLayout->addLayout(spbl);

    savePaintingFolderDialog = new QDialog();
    savePaintingFolderDialog->setLayout(overallLayout);
    savePaintingFolderDialog->show();

}
You're creating foldersList as a local variable in browseFolders. You should just be able to do "foldersList = new QListWidget();" (or maybe "this->foldersList = new QListWidget();" - I've not worked with C++ in quite a while). You're also passing foldersList to the refreshFoldersList function, though it doesn't accept it - I doubt that's connected but it could cause issues elsewehere.
 

The Following User Says Thank You to Rob1n For This Useful Post: