Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checkboxes not visible on OSX #308

Closed
krichardsson opened this issue Jul 26, 2017 · 3 comments
Closed

Checkboxes not visible on OSX #308

krichardsson opened this issue Jul 26, 2017 · 3 comments
Milestone

Comments

@krichardsson
Copy link
Contributor

Checkboxes are not visible in the "Log Blocks" tab on OSX.

How to reproduce

  1. Connect a Crazyflie
  2. Open the "Log Blocks" tab
  3. There should be checkboxes in the "Start" and "Write to file" columns but they are missing.

Screenshot showing problem

image

It actually looks like there is a checkbox in the top left corner. Maybe they are rendered in the wrong position? This is probably related to QT5.

Screenshot from the wiki of what is expected

image

Tested on

Cfclient version: 2016.4-90-g66ba354
System: darwin MacOS 10.12.5 (Sierra)
Python: 3.5.1
Qt: 5.9.1
PyQt: 5.9

Also tested on QT 5.8 with the same result

@jburgues
Copy link

jburgues commented Sep 7, 2017

I can confirm that the hypothesis of krichardsson about the checkboxes being rendered in a wrong position is correct. In fact, there are two problems. First, the checkboxes of the column "Start" are supposedly well located but are invisible and unclickable. Second, the checkboxes corresponding to the "Write to file" column are all overlapping in the top left corner (see picture below)

cfclient_bug2

If now I click on "Write to file" cell of the last row (Barometer), it can be seen that the checkbox on the top left corner gets checked (see picture below). I changed the source code to trigger the "Start" action when clicking the "Write to file" action. In this way, I can see the checkboxes of the "Start column" appear in their correct location, although with some undesired transparency. This latter bug was already reported in https://bugreports.qt.io/browse/QTBUG-42961

cfclient_bug1

I recommend browsing through the following links, as other users are experiencing similar problems with checkboxes in QT:
https://bugreports.qt.io/browse/QTBUG-32968?jql=text%20~%20%22checkbox%22
https://bugreports.qt.io/browse/QTBUG-13635

@krichardsson
Copy link
Contributor Author

krichardsson commented Nov 2, 2017

I found that it is the rendering of the checkboxes that is the problem.
In ui/tabs/LogBlockTab.py, in class CheckboxDelegate, method paint(): for columns 3 and 4 QApplication.style().drawControl(QStyle.CE_CheckBox, s, painter) is called to draw the checkboxes but they are rendered in the wrong location on OS X. By rendering some other type of graphical element we can see that the it is only the check box that is not working.
For instance by replacing the call with

s.text = "*"
QApplication.style().drawControl(QStyle.CE_CheckBoxLabel, s, painter)

will draw stars where we expected the checkboxes.

I found https://bugreports.qt.io/browse/QTBUG-40833 with a workaround to solve the problem.

By translating the painter coordinate system while painting the checkboxes we can force them to be drawn in the correct location. This should only be done on OS X though.

painter.save()
painter.translate(s.rect.topLeft())
QApplication.style().drawControl(QStyle.CE_CheckBox, s, painter)
painter.restore()

@krichardsson
Copy link
Contributor Author

It seems as the problem only occurs when the checkbox has State_Enabled.

@krichardsson krichardsson added this to the next_release milestone Nov 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants