Skip to content

Instantly share code, notes, and snippets.

@sudo-give-me-coffee
Created August 6, 2022 20:53
Show Gist options
  • Save sudo-give-me-coffee/928f17e229c3c80ff6ffb45fe1b4d122 to your computer and use it in GitHub Desktop.
Save sudo-give-me-coffee/928f17e229c3c80ff6ffb45fe1b4d122 to your computer and use it in GitHub Desktop.

Create your normal derivation

  1. Create C++ and .h files
  2. Do your stuff

Reimplement the paintEvent with:

void YourClass::paintEvent(QPaintEvent *event){
    Q_UNUSED(event)

    QStyleOption option;
    option.init(this);

    QPainter painter(this);

    style()->drawPrimitive(QStyle::PE_Widget, &option, &painter, this);
}

Now YourClass will work as valid style selector

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment