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. is it possibel to add a background-imnage to the QDial?

is it possibel to add a background-imnage to the QDial?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 591 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.
  • Z Offline
    Z Offline
    zxh11
    wrote on last edited by
    #1

    I tried adding a background image to a QDial in Qt Designer, but it didn't work.
    73217384-8e1a-49cd-894a-cbdd24db134f-image.png

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      zxh11
      wrote on last edited by
      #2

      I also want to determine if all qwidgets can have a background image.
      I know how to add background image to QPushButton and QLable via stylesheet, but the same method doesn't work on QDial

      1 Reply Last reply
      0
      • Kent-DorfmanK Offline
        Kent-DorfmanK Offline
        Kent-Dorfman
        wrote on last edited by Kent-Dorfman
        #3

        No. ancestor of QDial is QWidget, which does not directly support images. QLabel, which is on a different inheritance branch of QWidget does support.

        You would have to design a custom widget to do what you want to do. It's not possible with the canned widget, unless some transparency witchcraft of overlaid widgets will work...

        1 Reply Last reply
        0
        • JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          https://doc.qt.io/qt-5/stylesheet-reference.html#background-prop

          This property is supported by QAbstractItemView subclasses, QAbstractSpinBox subclasses, QCheckBox, QComboBox, QDialog, QFrame, QGroupBox, QLabel, QLineEdit, QMenu, QMenuBar, QPushButton, QRadioButton, QSplitter, QTextEdit, QToolTip, and plain QWidgets.

          https://bugreports.qt.io/browse/QTBUG-61481

          It would be useful if QDial had support for stylesheets.

          The only stylesheet property that works with QDial is background. It should have ::handle and ::groove sub controls like QSlider as long as it inherits QAbstractSlider.

          However, if you don't use a stylesheet then according to https://www.qtcentre.org/threads/29003-Trying-to-create-custom-QDial?p=136681#post136681

          I think I will have to subclass QDial and overload paintEvent(). I am able to achieve desired behavior doing so. Wanted to use Stylesheet for this. Let me know if you have a solution with Stylesheet.

          1 Reply Last reply
          1

          • Login

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