Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 2

Qt-interest Archive, April 2008
Multiple stylesheets used in the application


Message 1 in thread

Hi all,
I need to have different styleSheets for the main window, for child 
windows and for the dialogs. For these reason I write my code like this:

// this is the main form with its skin setup
   WMainForm.SetSkin("black.qss");
   WMainForm.show();

    QMachineListFrm *WToolsetListFrm = 
QToolsetListFrm::GetInstance(NULL, "WindowToolsetsList");
// this works
    WMachineListFrm->SetSkin("coffee.qss");
    WMachineListFrm->show();
...
    QToolsetListFrm *WToolsetListFrm = 
QToolsetListFrm::GetInstance(NULL, "WindowToolsetsList");
// this doesn't work, the window will have WMainForm stylesheet
    WToolsetListFrm->SetSkin("pagefold.qss");
    WToolsetListFrm->setParent(WMainForm.ui.stackedWidget);
    WToolsetListFrm->show();

where:

void QToolsetListFrm::SetSkin(QString asSkinFileName)
{
    QFile file(asSkinFileName);
    QString as;
    file.open(QFile::ReadOnly);
    as = QLatin1String(file.readAll());
    setStyleSheet(as);
}
//------------------------------------------------------------------------------


void QMachineListFrm::SetSkin(QString asSkinFileName)
{
    QFile file(asSkinFileName);
    QString as;
    file.open(QFile::ReadOnly);
    as = QLatin1String(file.readAll());
    setStyleSheet(as);
}
//------------------------------------------------------------------------------

but windows who have WMainForm as their parent are skinned as WMainForm 
also if I set a different stylesheet by code.

Is there any thing I don't know to solve this annoying problem?
begin:vcard
begin:vcard
fn:Massimo Manca
n:Manca;Massimo
org:Micron Engineering di Massimo Manca
adr:;;via della Ferriera, 48;Pordenone;PN;33170;ITALIA
email;internet:massimo.manca@xxxxxxxxxxxxxxxxxxxx
tel;work:+39 0434 1856131
tel;fax:+39 0434 1851032 / 178 273 3543
tel;cell:+39 349 4504979
url:http://www.micronengineering.it
version:2.1
end:vcard