[Qt] Qt stylesheets and URL problem

zeljko zeljko at holobit.net
Tue Dec 22 08:18:34 CET 2009


On Monday 21 December 2009 22:38, Marcin Dębicki wrote:
> I have code:
>
> s:=TStringList.Create;
>   s.LoadFromFile(fname);
>   w:=s.Text;
>   Dir := GetCurrentDir;
>   SetCurrentDir(ExtractFilePath(fname));
>   QApplication_setStyleSheet(QApplicationH(QCoreApplication_instance), @w);
>   SetCurrentDir(Dir);
>   s.Free;
>
> Where w is a widestring. I am trying to load custom stylesheet with
> urls to pngs for some controls (checkboxes and so on). Problem is that
> for some reason no images are loaded. So the question is does Qt need
> some additional library to handle png files? image plugins are
> properly loaded (I use webview there also).
> Additionally I have looked into bindings source and I see:
>
> void QApplication_setStyleSheet(QApplicationH handle, PWideString sheet)
> {
> 	QString t_sheet;
> 	copyPWideStringToQString(sheet, t_sheet);
> 	((QApplication *)handle)->setStyleSheet(t_sheet);
> }
>
> while according to this (working example):
>
> QFile file(":/qss/" + sheetName.toLower() + ".qss");
>     file.open(QFile::ReadOnly);
>     QString styleSheet = QLatin1String(file.readAll());
>
>     ui.styleTextEdit->setPlainText(styleSheet);
>     qApp->setStyleSheet(styleSheet);
>
> There should be non unicode string passed

Well, you can go around it, but I doubt that it is a problem.

 s:=TStringList.Create;
   s.LoadFromFile(fname);
   w := UTF8Encode(s.Text);
   Dir := GetCurrentDir;
   SetCurrentDir(ExtractFilePath(fname));
   QApplication_setStyleSheet(QApplicationH(QCoreApplication_instance), @w);
   SetCurrentDir(Dir);
   s.Free;






More information about the Qt mailing list