Subbed QFileIconProvider, set it to return only one icon, makes no difference



  • I have a pretty standard QFileDialog that I am using to have the user select a directory, and because I want to be able to change the icons seen, I have subclassed QFileIconProvider and am using my own function to provide the icon. Like this:

    @ subbedFileIconProvider tempIconprovider;
    QFileDialog aFileDialog;
    aFileDialog.setIconProvider(&tempIconprovider);
    QString dir = aFileDialog.getExistingDirectory(0, tr("Select directory"),
    QString(),
    QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);@

    The subbedFileIconProvider contains an icon function, like this:

    @QIcon subbedFileIconProvider::icon(const QFileInfo &info) const
    {
    return QIcon(":/workplace/customIcon");
    }@

    I know it's being called as I set a breakpoint there and watch it being called repeatedly. However, the file dialog looks exactly the same. No change. So what am I missing? I though I could control the icon that would be displayed on screen in the file selection dialog, but it makes no difference at all.


  • Lifetime Qt Champion

    Hi,

    Your icon provider is not used, getExistingDirectory is a static function so you are not using the file dialog you think you are using

    Hope it helps


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.