[Interest] QFileSystemModel broken in Qt5? (minimal example)

Wilhelm wilhelm.meier at fh-kl.de
Tue Jan 22 08:56:43 CET 2013


Am 22.01.2013 08:50, schrieb Mandeep Sandhu:
> On Tue, Jan 22, 2013 at 12:47 PM, Wilhelm <wilhelm.meier at fh-kl.de> wrote:
>> Hi all,
>>
>> I have this minimal example:
>>
>> -----
>> #include <QApplication>
>> #include <QFileSystemModel>
>>
>> int main(int argc, char *argv[])
>> {
>>       QApplication a(argc, argv);
>>
>>       QFileSystemModel* fileSystemModel = new QFileSystemModel(0);
>>       fileSystemModel->setRootPath(QDir::homePath());
>>       fileSystemModel->setFilter(QDir::AllDirs | QDir::Files);
>>
>>       return a.exec();
>> }
>> -----
>>
>> If I compile against Qt5 and run this small program, I get the following
>> run-time error:
>>
>> Starte /home/lmeier/fd1-build-QT5-Debug/fd1...
>> QObject: Cannot create children for a parent that is in a different thread.
>> (Parent is QFileSystemWatcher(0xa82d80), parent's thread is
>> QThread(0xa47420), current thread is QFileInfoGatherer(0xa84048)
>
> Your code seems to be fine.
>
> QFSM, IIRC, uses a separate thread for scanning the FS and updating
> the model (in Qt4.7+ at least). So this message seems to be related to
> that thread.

Yes. All my code was fine up to Qt 4.8.3.

> Something broke there in Qt5?

Since QFileDialog also uses QFSM I wonder why I should be the first one 
to hit this problem ...

>
> -mandeep
>
>
>>
>> -----
>>
>> The error doesn't show up with Qt 4.8.3 at least.
>>
>> So, what's wrong here?
>>
>> --
>> Wilhelm
>>
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest


-- 
Wilhelm




More information about the Interest mailing list