[Android-development] What's with the theming?

maitai at virtual-winds.org maitai at virtual-winds.org
Mon Sep 29 23:12:57 CEST 2014


Hello,

If your app is widget-based, using ministro to deploy it (and I think 
from 5.4 that won't be even necessary), you can load an android-style by 
doing something like:

         QStyle * android=QStyleFactory::create("Android");
         qApp->setStyle(android);

(note: In fact I have my own android style derived from that but that's 
another story...)

Then you can set your application's palette as you wish, or even 
styleSheet, doing something like

         QString styleA="QHeaderView::section {"
                 "color: black;}"
         "QToolBox::tab:unselected{color:black;"
                 "background-color:qlineargradient(x1: 0, y1: 0, x2: 1, 
y2: 0,"
                 "stop: 1 #fffb90, stop: 0 #ffd800);}"
         ...etc...
         "QDateTimeEdit::down-button {width: 0px; height: 0px;}"
                 ;
         qApp->setStyleSheet(styleA);

and/or

     QPalette p=qApp->palette();
     p.setColor(QPalette::Window, QColor(53,53,53));
     p.setColor(QPalette::Button, QColor(53,53,53));
     ... etc ...
     QBrush brush = p.window();
     brush.setColor(brush.color().light(300));
     QColor dis=brush.color();
     p.setColor(QPalette::Disabled, QPalette::Text, dis); // color menu 
item base
     p.setColor(QPalette::Disabled, QPalette::Light, QColor(53,53,53));
     p.setColor(QPalette::Disabled, QPalette::WindowText, dis);
     qApp->setPalette(p);

The bottom line being that imo setting the palette or stylesheet from 
qcreator/design view is a bit useless on android ;)

I'm not sure to be on topic, but I hope this helps

Philippe.

Le 29-09-2014 22:31, Harri Pasanen a écrit :
> Hi again,
> 
> I recall vaguely following from the sidelines about something in
> Qt/Necessitas picking up the standard Android theme and using that on
> Android for Qt widget based apps.  Did something along those lines 
> happen?
> 
> Anyway, I have noticed that nowadays, since 5.2 or so, my carefully
> selected palette I'm using in the designer gets overwritten on Android.
> But the resulting buttons look the drab Qt default, black text on light
> gray.   On my Nexus 7 nothing appears to have those colors, everything
> is more or less white on black.
> 
> My users don't care, as I'm literally writing software for the blind.
> It bugs be a bit though, I imagine the battery consumption is higher
> with all that white.
> Plus for some users with limited vision it would be good if I could
> select a color palette that is high contrast.
> 
> I honestly don't care if the default is Android, but I do care that I
> can pick what I use.
> 
> Any hints?
> 
> Thanks,
> 
> Harri
> 
> PS. I think this is the third time I've posted a variation of this 
> mail,
> so far no answers.
> _______________________________________________
> Android-development mailing list
> Android-development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/android-development



More information about the Android-development mailing list