1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Can I override setStylesheet() function using CSS file from theme?

Discussion in 'Help' started by amicus tuus, Aug 6, 2017.

Moderators: E.T., Zoroark
  1. amicus tuus

    amicus tuus Litten is life

    Joined:
    Jan 2, 2017
    Messages:
    10
    Likes Received:
    13
    My theme is being messed up with this function. see
    [​IMG]

    Full function is this :
    Code (text):
    1. void BattlePokeButton::update()
    2. {
    3.     setText(p->nickname() + "\n" + QString::number(p->life()) + "/" + QString::number(p->totalLife()));
    4.     int status = p->status();
    5.     if (status == Pokemon::Koed || status == Pokemon::Fine) {
    6.         setStyleSheet("");
    7.     } else {
    8.         setStyleSheet("background: " + Theme::StatusColor(status).name() + ";");
    9.     }
    10.  
    It overrides the status inflicted pokemon's button which looks out of place. Is there any way to prevent it?
     
  2. Veteran Padgett

    Veteran Padgett Active Member Developer Developer

    Joined:
    May 31, 2013
    Messages:
    285
    Likes Received:
    210
    PO Trainer Name:
    Veteran Padgett
    The setStyleSheet function replaces existing css style for that button. To make it theme friendly, the update function would have to be changed. Maybe it should use something like addClass("poisoned"); Then you can edit the style for ".poisoned" in the css. I haven't made any themes so I could be wrong about messing with css, but the bottom line is to not use the setStyleSheet function.

    Even if this is fixed you will have to wait for the next client version, or you could get a fixed version of the source code and build your own client.
     
  3. amicus tuus

    amicus tuus Litten is life

    Joined:
    Jan 2, 2017
    Messages:
    10
    Likes Received:
    13

    Yeah I was wondering the same if I could use dynamic property. The problem is that Qt CSS does not handle dynamic properties if changed from .css file. I actually tried using
    Code (text):
    1. BattlePokeButton[status=4]{
    2. background:orange;
    3. }
    It did not work however. I don't want to make changes in client code. I am not even a good programmer. If someone experienced like Coyotte, or Lamperi, or anyone else could tell me a way to handle this problem then it'd be great.
     
Moderators: E.T., Zoroark