I'm using stylesheet for my new widget. I want to add a reload button just for designing. So I add a stylesheet.txt in Resouces/.../xxx.qrc file as the style sheet to apply for my widget. And I have a QPushButton to trigger setStyleSheet() with a QFile to open the stylesheet.txt. And I want to edit the txt outside the program with defaut editor in system. But I found that the resources files are not refreshed which means when I edit the txt, the txt doesn't reload in the program. Any idea how can I reload the file or any solution, please?
General suggestion: do not put resources in .qrc during debug / design. I recommend to use a QDir::setSearchPaths
instead:
void Application::setDirs()
{
#ifdef QT_DEBUG
QDir dir( QGuiApplication::applicationDirPath() );
dir.cd( "C:/DotaClient" );
QDir::setSearchPaths( "qml", QStringList( dir.absolutePath() ) );
#else
QDir::setSearchPaths( "qml", QStringList( ":/DotaClient/" ) );
#endif
}
Access:
m_mainView->setSource( QUrl( "qml:Root/Root.qml" ) );
Or something like background-image:url(images:Root/root_bg.png);
in QSS.
In this case, file Root.qml
will be looked in C:/DotaClient/Root/Root.qml
in debug build (with possibility of dynamic reloading), and in :/DotaClient/Root/Root.qml
(in resources) in release build.