You already have a list, one file per list entry.
Do you want to split each filename?
Cheers,
_
You already have a list, one file per list entry.
Do you want to split each filename?
Cheers,
_
I think you and the OP are interpreting the word "split" differently. If he wants to display each file in the list, then it makes no sense at all to split the file names into smaller pieces.Split each filename according to what criteria?
I think he just doesn't understand how to retrieve the individual file names from the list.
Qt Code:
QString fileName; foreach( fileName, dirList ) { // "fileName" now contains the name of one of the files in the list // Use QPixmap to read the image from the file // Use QLabel::setPixmap() to display the pixmap on a QLabel (for example) // or use QGraphicsPixmapItem to show it in a QGraphicsScene (for example) }To copy to clipboard, switch view to plain text mode
iswaryasenthilkumar (16th February 2015)
Just for the record, this is not a good idea.
1) Having the loop variable outside the loop makes it much harder for the compiler to do any loop optimization, because its life time exceeds that of the loop
2) Having a non-const ref loop variable means each loop iteration copies the list element. Inexpensive for a ref-counted type like QString but still unnecessary.
Even for a ref-counted class it could lead to a deep-copy if any of the variable type's non-const method is called, even if there is a const variant, e.g. operator[]
So for the example of a string list the way to write that foreach is
Qt Code:
{ }To copy to clipboard, switch view to plain text mode
Cheers,
_
iswaryasenthilkumar (16th February 2015)
I never use foreach() anyway, so I'm not that familiar with the syntax. I'm a QStringList::const_iterator type myself, in which case I would extract the filename to a const QString reference inside the iterator loop.
But as wysota says...
iswaryasenthilkumar (16th February 2015)
thank you all i got answer based on all your tips i used QStringList:ir.entryList
Thank you all
Bookmarks