QCheckBox painting problems on macOS
-
It appears as though QCheckBox shows Qt::Checked when it is actually Qt::PartiallyChecked for Qt-5.11.0 on macOS. This is the case when QCheckBox::checkState() returns Qt:PartiallyChecked. This is easily reproducible by previewing a tristate QCheckBox in Qt Creator.
There is another possibly related issue where a QCheckBox in a QTableView does not repaint itself when ::setCheckState(Qt::Checked) is called until the table view is redrawn, for example when the cell in question is selected.
Help??
-
Hi,
What version of macOS are you running ?
Can you give a minimal compilable example showing that ?
-
Latest Mac OS X and QT 5.11.0. You can reproduce the Partially checked bug in QT creator by just alt-clicking on a checkbox that is tristate. You will never see the partially checked symbol.
I’ll need to make an example for the other bug.
-
Just slap these into the vanilla QtWidgets app template to reproduce the bug where it doesn't paint the tristate checkbox on Qt-5.11.0 on macOS. The repaint bug does not appear to occur here with QTableWidget as it does in my QTableView application. I will make an example for that if I have time, but this is enough for now.
#include "widget.h" #include "ui_widget.h" #include <QTableWidget> #include <qDebug> Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget) { ui->setupUi(this); tw = new QTableWidget(this); tw->setColumnCount(2); tw->setRowCount(2); QTableWidgetItem *item = new QTableWidgetItem; item->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsAutoTristate); item->setCheckState(Qt::Unchecked); tw->setItem(0, 0, item); this->startTimer(1000); } Widget::~Widget() { delete ui; } void Widget::timerEvent(QTimerEvent *event) { QTableWidgetItem *item = tw->item(0, 0); if(item->checkState() == Qt::Checked) { item->setCheckState(Qt::PartiallyChecked); } else if(item->checkState() == Qt::PartiallyChecked){ item->setCheckState(Qt::Unchecked); } else { item->setCheckState(Qt::Checked); } qDebug() << item->checkState(); }
#ifndef WIDGET_H #define WIDGET_H #include <QWidget> namespace Ui { class Widget; } class QTableWidget; class Widget : public QWidget { Q_OBJECT QTableWidget *tw; public: explicit Widget(QWidget *parent = 0); ~Widget(); void timerEvent(QTimerEvent *event); private: Ui::Widget *ui; }; #endif // WIDGET_H
-
I posted a bug here: