QRegExp, how to find image files?

I am not proficient with regexp, and I need help to find image files.
I made following:


    QRegExp rx("*.jpg");
    rx.setCaseSensitivity(Qt::CaseInsensitive);
    rx.setPatternSyntax(QRegExp::Wildcard);

    QDir directory(this->currentSrcDir);

    QStringList allFiles = directory.entryList(QDir::Files | QDir::NoSymLinks);
    QStringList matchingFiles;

     foreach (QString file, allFiles)
     {
         if (rx.exactMatch(file))
             matchingFiles << file;
     }

I don’t know how to make regexp that it gives me all files with extensions *.jpg *.png *.jpeg etc.
Tried to find on the net, but after roughly 1.5 hours of googling, I found only examples with one extension, or using QFileDialog, which I do not want.

Thanks!

For example, the following code sets three name filters on a QDir to ensure that only files with extensions typically used for C++ source files are listed:

     QStringList filters;
     filters << "*.cpp" << "*.cxx" << "*.cc";
     dir.setNameFilters(filters);

Qt 4.5.3: QDir Class Reference

Works, thanks.

I am having difficulties rasing an exception. Does Qt4 has some common error message dialog?

For example, user must fill directory, if directory not exists, I need to raise an exception where error message will be shown on screen and function will end.

I cant’t find how to “throw” a visual exception. Not even on google, and I don’t understand how to use QErrorMessage class.
help!

Resolved:

   QMessageBox msgBox;
   msgBox.setIcon(QMessageBox::Critical);
   msgBox.setText("Destination directory empty or does not exists");
   msgBox.setInformativeText("Please select valid destination directory");
   msgBox.setStandardButtons(QMessageBox::Ok);
   msgBox.setDefaultButton(QMessageBox::Ok);
   msgBox.exec();