Mac OS X and Qt Stylesheets
-
Hi all,
I have been banging my head on the wall for the past two days trying to use stylesheets on Mac OS X.
The code below will NOT set the background if the STYLESHEETS macro is defined (-DSTYLESHEETS).
However, when it is not defined and I use the QPalette approach, it works but this is really not the way I intend to implement what I have to do. Any ideas will be warmly welcome!@
#include <QApplication>
#include <QFrame>
#include <QPalette>int main( int argc, char** argv )
{
QApplication app( argc, argv );QFrame* frame = new QFrame;
#ifdef STYLESHEETS
frame->setStyleSheet( "background-image: url( 'gnu.png' );" );
#else
QPalette p;
QPixmap bg( "gnu.png" );
bg = bg.scaled( 800, 400, Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
p.setBrush( frame->backgroundRole(), bg );
frame->setPalette( p );
#endif
frame->show();return app.exec();
}
@ -
Well, after scanning through old code, it turns out that you can't put whitespace in the url()...
This code will work: @frame->setStyleSheet( "background-image: url('gnu.png');" );@ but this will not: @frame->setStyleSheet( "background-image: url( 'gnu.png' );" );@
So much time lost...