Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Override painting behavior without subclassing widgets
Forum Updated to NodeBB v4.3 + New Features

Override painting behavior without subclassing widgets

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 222 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Ewan Green
    wrote on last edited by Ewan Green
    #1

    I would like to change the way in which widgets are painted, similar to what you would achieve using stylesheets. However, I'm unable to subclass any of the widgets in a productive manner (I would have to override every paintEvent() for every widget I would want to change). The issue I have with stylesheets is the inability to set different border-images for each side; which appears to be completely possible in QML (see this), but not in normal Qt for C++. Is there a workaround?

    In case you're wondering, in pursuit of offering an alternative solution:
    I am trying to style an existing program. Its design is established, and to change integral portions of the UI would not be viable for 1 pull request; it would create plenty of conflicts and apparent convolutions for new contributors. I have to keep things relatively simple as this is largely other peoples' code.

    EDIT: I've discovered that the border-image property technically does what I want to do. I think it's a little counter-intuitive that only the topmost-level shorthand is available, as I'd love to be able to use border-image-slice, border-image-width, border-image-outset, and border-image-source on their own. And I haven't figured out how to make this work like I want, but that doesn't pertain to the question asked initially (I will make a new topic and close this one).

    Ewan Green

    eyllanescE 1 Reply Last reply
    0
    • E Ewan Green

      I would like to change the way in which widgets are painted, similar to what you would achieve using stylesheets. However, I'm unable to subclass any of the widgets in a productive manner (I would have to override every paintEvent() for every widget I would want to change). The issue I have with stylesheets is the inability to set different border-images for each side; which appears to be completely possible in QML (see this), but not in normal Qt for C++. Is there a workaround?

      In case you're wondering, in pursuit of offering an alternative solution:
      I am trying to style an existing program. Its design is established, and to change integral portions of the UI would not be viable for 1 pull request; it would create plenty of conflicts and apparent convolutions for new contributors. I have to keep things relatively simple as this is largely other peoples' code.

      EDIT: I've discovered that the border-image property technically does what I want to do. I think it's a little counter-intuitive that only the topmost-level shorthand is available, as I'd love to be able to use border-image-slice, border-image-width, border-image-outset, and border-image-source on their own. And I haven't figured out how to make this work like I want, but that doesn't pertain to the question asked initially (I will make a new topic and close this one).

      eyllanescE Offline
      eyllanescE Offline
      eyllanesc
      wrote on last edited by
      #2

      @Ewan-Green implement a custom QGraphicsEffect

      If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved