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. QT paintEvent with custom widget
QtWS25 Last Chance

QT paintEvent with custom widget

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 3.2k Views
  • 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.
  • N Offline
    N Offline
    neel2818
    wrote on last edited by
    #1

    I have one custom widget and in custome widget we have many widget included mean label,lineedit
    etc. In custom widget we have applied stylesheet through paintEvent. but i want some of the
    widgets inside the custome widget should not use the stylesheet based on paintEvent
    so how to remove (not to apply stylesheet) that widget from paintEvent method ?

    Thanks,
    Neel

    1 Reply Last reply
    0
    • D Offline
      D Offline
      ddurhamdavyandbeth.com
      wrote on last edited by
      #2

      I'm assuming you're using traditional Qt (e.g. not QML or something).

      I'm not entirely sure by what you mean by "applied stylesheet through paintEvent", but perhaps I can suggest that you use a more specific CSS selector when setting the style.

      For example:

      @
      QPushButton,QLabel { background: green; }
      @

      .. will only style the QPushButton and QLabel objects

      Or:

      @
      #myText { color: green; }
      @

      .. will only style the color of objects with a QObject::objectName() of "myText".

      Or:

      @
      .QWidget { background: red; }
      @

      .. will only style objects of class QWidget but not sub-classes of QWidget

      Check out http://doc.qt.nokia.com/latest/stylesheet-syntax.html#selector-types for more info.

      Also, something I haven't seen documented, but is clearly in the code is that a property can be set to "native" (e.g. "border: native") to basically say that you want that property styled natively as if no stylesheet had been set.

      Apologies if I'm not understanding the question.

      [EDIT: code formatting, please wrap in @-tags, Volker]

      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