[Qt] Qt stylesheets and URL problem

Marcin Dębicki alterfenix at gmail.com
Mon Dec 21 22:38:54 CET 2009


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

Best regards,
Marcin Dębicki




More information about the Qt mailing list