PDA

View Full Version : Problem to setstylesheet



phillip_Qt
11th April 2008, 11:58
Hi all.
I ve a problem. the following code i9s not working for me.

Pointer->LoadStyleSheet("pagefold.qss");
ui.m_pLowerStatusBar->setStyleSheet("QWidget#widget {background-color: blue}");

Its loading the qss file only. inside it QWidget is gray. But there is a widget. itried to fill like 2nd line. But its not working.
same code is working fine if i give like
Pointer->LoadStyleSheet("default.qss");
ui.m_pLowerStatusBar->setStyleSheet("QWidget#widget {background-color: blue}");

Can any body help me?:(

Thank you All.

Junior
11th April 2008, 15:44
Are you ensuring that you are reading the file in as one long string before trying to set it? Normally the default.qss is blank so it probably would work in any case.

Example extracted from ref: http://doc.trolltech.com/4.3/widgets-stylesheet-stylesheeteditor-cpp.html



void StyleSheetEditor::loadStyleSheet(const QString &sheetName)
{
QFile file(":/qss/" + sheetName.toLower() + ".qss");
file.open(QFile::ReadOnly);
QString styleSheet = QLatin1String(file.readAll());

ui.styleTextEdit->setPlainText(styleSheet);
qApp->setStyleSheet(styleSheet);
ui.applyButton->setEnabled(false);
}


If you are using the qss from the resource (rcc), it might be helpful to ensure that you resource init it in your main as well ( Q_INIT_RESOURCE(resource name); ).

Just a couple of things that come to mind.

phillip_Qt
13th April 2008, 08:15
Are you ensuring that you are reading the file in as one long string before trying to set it? Normally the default.qss is blank so it probably would work in any case.

Example extracted from ref: http://doc.trolltech.com/4.3/widgets-stylesheet-stylesheeteditor-cpp.html



void StyleSheetEditor::loadStyleSheet(const QString &sheetName)
{
QFile file(":/qss/" + sheetName.toLower() + ".qss");
file.open(QFile::ReadOnly);
QString styleSheet = QLatin1String(file.readAll());

ui.styleTextEdit->setPlainText(styleSheet);
qApp->setStyleSheet(styleSheet);
ui.applyButton->setEnabled(false);
}


If you are using the qss from the resource (rcc), it might be helpful to ensure that you resource init it in your main as well ( Q_INIT_RESOURCE(resource name); ).

Just a couple of things that come to mind.

I think Q_INIT_RESOURCE is not so necessary. i ve posted a query in forumand got replied. Its also working.

phillip_Qt
14th April 2008, 07:57
Hi All.
I m still facing same problem.
I ve a doubt. can i paint a specific area like follow.

pointer->LoadStyleSheet("pagefold.qss");
// Is it possible?
ui.m_specificArea ->setStyleSheet("QWidget#specificArea {background-color: blue}");

I ll thankful if any body let meknow.