![]() |
2010-07-05
, 13:32
|
Posts: 353 |
Thanked: 263 times |
Joined on Dec 2009
@ Finland
|
#2
|
![]() |
2010-07-05
, 13:36
|
Posts: 341 |
Thanked: 57 times |
Joined on Nov 2009
|
#3
|
How about changing all the "-->" to "->"? I don't think there is a operator -->
![]() |
2010-07-05
, 14:10
|
Posts: 726 |
Thanked: 345 times |
Joined on Apr 2010
@ Sweden
|
#4
|
![]() |
2010-07-05
, 14:26
|
Posts: 341 |
Thanked: 57 times |
Joined on Nov 2009
|
#5
|
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!!"); } }
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(); }
![]() |
2010-07-05
, 14:31
|
Posts: 726 |
Thanked: 345 times |
Joined on Apr 2010
@ Sweden
|
#6
|
QListWidget *foldersList = new QListWidget();
The Following User Says Thank You to Joorin For This Useful Post: | ||
![]() |
2010-07-05
, 14:32
|
Posts: 3,617 |
Thanked: 2,412 times |
Joined on Nov 2009
@ Cambridge, UK
|
#7
|
Alright, here's the refreshFoldersList() function
And here's the browseFolders() function (called first!):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!!"); } }
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(); }
The Following User Says Thank You to Rob1n For This Useful Post: | ||
![]() |
2010-07-05
, 14:34
|
Posts: 13 |
Thanked: 12 times |
Joined on Apr 2010
@ Finland
|
#8
|
The Following User Says Thank You to tommiasp For This Useful Post: | ||
![]() |
2010-07-05
, 14:56
|
Posts: 341 |
Thanked: 57 times |
Joined on Nov 2009
|
#9
|
![]() |
2010-07-05
, 15:06
|
Posts: 726 |
Thanked: 345 times |
Joined on Apr 2010
@ Sweden
|
#10
|
Hey guys .. Well ever since I've started programming in Qt, I've been having problems regarding scope visibility of objects I've defined .. Till now I've managed to find ways to get around these things but now its getting annoying ..
For example, I have this class defined called Canvas:
Now even though foldersList is private, refreshFoldersList() should be able to 'see' it, right ? But in my case it can't .. ! I first initialize foldersList in the browseFolders() function and then from within browseFolders(), I call refreshFoldersList() ... Any code inside refreshFoldersList() dealing with foldersList immediately throws a segmentation fault ... I've checked the pointer values for foldersList when the scope is in browseFolders() and refreshFoldersList() .. the values don't match .. its like either I'm trying to access something I'm not supposed to, or that I'm trying to access an object which has not been initialized yet ..
Any clues on this ?
Second problem is still an ongoing issue:
A related issue ... I have another class MainWindow (inherited from QMainWindow) .. In this class I have an instance of the class Canvas .. this instance is named canvas .. I initialize canvas in MainWindow's constructor, and set canvas's parent to the MainWindow instance initializing it .. based on this, I used the following code to access a MainWindow function from within the Canvas class:
But again, I would like to know the nature of these problems .. Am I doing something wrong or what ?
Last edited by ahmadka; 2010-07-05 at 14:59.