View Full Version : QUrl: file in the current dir
lirq
5th January 2009, 23:43
Getting absolute path to file is simple:
QUrl("file://<path>/<filename>")
But I want to get QUrl representation of file in the current directory. Something like QUrl("file://stylesheet.css") but this doesn't work.
How to do this?
wysota
6th January 2009, 00:00
Use QUrl::fromLocalFile().
lirq
6th January 2009, 00:49
I tried but unsuccessful. I want to apply my own css file to QWebFrame object.
This works:
QWebSettings *settings = QWebSettings::globalSettings();
settings->setUserStyleSheetUrl(QUrl("file:///home/lirq/Programming/test/style.css") );
But this doesn't:
QWebSettings *settings = QWebSettings::globalSettings();
settings->setUserStyleSheetUrl( QUrl::fromLocalFile("style.css") );
wysota
6th January 2009, 10:13
Use an absolute path to the file, not relative one - file:///style.css and file:///home/lirq/.../style.css are two different paths.
lirq
6th January 2009, 11:43
In case of absolute path it's needed to get path to my application. How to do this?
wysota
6th January 2009, 11:52
QCoreApplication::applicationDirPath() or you can probably simply use QFile::absolutePath() to get absolute path from relative one.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.