0

The only way I found to do this is here: How to make QCheckBox readonly, but not grayed-out. This, however, disables mouse interactions with the control. But I need the tooltip to be displayed when mouse is over the control. How can I achieve this?

Community
  • 1
  • 1
The Quantum Physicist
  • 24,987
  • 19
  • 103
  • 189
  • 1
    This seems a horrible thing to do from a ux pov, since it completely undermines the normal behaviour. What's the use-case? – ekhumoro Jul 28 '16 at 18:26
  • If you don't need to have the checkbox not grayed out, you can disable it; the tooltip still displays for a disabled checkbox. I'm not sure how to make it disabled without graying it out – Peter Wang Jul 29 '16 at 18:08
  • There's an option that I control somewhere else that I don't want to look gray. That's all. @PeterWang – The Quantum Physicist Jul 29 '16 at 22:49
  • There's an option that I control somewhere else that I don't want to look gray. That's all. @ekhumoro – The Quantum Physicist Jul 29 '16 at 22:49

2 Answers2

3

If I've understood correctly, this is what you'd be asking for, a disabled checkbox showing tooltips:

 import sys
 from PyQt4 import QtGui, QtCore


 class Example(QtGui.QWidget):

      def __init__(self):
           super(Example, self).__init__()
           self.initUI()

      def initUI(self):
           self.cb = QtGui.QCheckBox('Disabled CheckBox showing tooltips', self)
           self.cb.move(20, 20)
           self.cb.toggle()
           # self.cb.setEnabled(False)
           # self.cb.setStyleSheet("color: black")
           # self.cb.setAttribute(QtCore.Qt.WA_AlwaysShowToolTips)
           self.cb.setToolTip ('my checkBox')
           self.cb.toggled.connect(self.prevent_toggle)

           self.setGeometry(300, 300, 250, 50)
           self.setWindowTitle('QtGui.QCheckBox')
           self.show()

      def prevent_toggle(self):
           self.cb.setChecked(QtCore.Qt.Checked)

 def main():
      app = QtGui.QApplication(sys.argv)
      ex = Example()
      sys.exit(app.exec_())


 if __name__ == '__main__':
      main()
BPL
  • 9,632
  • 9
  • 59
  • 117
2
#If your are not expecting this answer, sorry.

self.checkBox = QtGui.QCheckBox()
self.checkBox.setEnabled (False)
self.checkBox.setToolTip ('my checkBox')
Subin Gopi
  • 541
  • 2
  • 12