Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-96522

QSlider fail to repaint on macOS Monterey

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.14.0 RC2
    • GUI: Painting
    • None
    • macOS

    Description

      QSlider does not repaint on macOS Monterey.

      Steps to reproduce:

      1. Sample: put QSlider and QPlainTextEdit on a dialog, and connect signals of them, so that they show same value and update each others.
      2. On macOS 12 Monterey, drag slider, text edit shows correct value
      3. now change value in text edit, but slider won't repaint (though internally the value is correct in NSSlider)

      Notes:

      • Only an issue on Mac os 21 Monterey (I got Beta so far)
      • Do not set any stylesheet to the slider, so that Qt user cocoa native API to paint
      • If I applied customized stylesheet, then Qt paints the slider value correctly, therefore it seems to be something related to cocoa api.

      My Sample code:

      #include <QApplication>  
      #include <QDialog>
      #include <QSlider>
      #include <QPlainTextEdit>
      #include <QSpacerItem>
      #include <QGridLayout>
      #include <iostream>
      int main(int argc, char **argv)
      {
      	QApplication app(argc, argv);
      	QDialog dlg;
              // Create slider with value range 0-100
      	auto * slider = new QSlider(Qt::Horizontal, &dlg);
      	slider->setMinimum(0);
      	slider->setMaximum(100);
      	slider->setValue(50);	
              // Create text edit which display/sets the slider value
      	auto * edit = new QPlainTextEdit(&dlg);	// Layout
      	auto * grid = new QGridLayout;
      	grid->addWidget(edit, 0, 0);
      	grid->addWidget(slider, 1, 0);
      	dlg.setLayout(grid);	
              // slider signal handling, update value to edit
      	dlg.connect(slider, &QSlider::valueChanged, [edit](int value){
      		std::cout << "onSliderValueChanged: " << value << std::endl;
      		edit->blockSignals(true);
      		edit->setPlainText(std::to_string(value).c_str());
      		edit->blockSignals(false);
      	});
              // edit signal handling, update value to slider
      	dlg.connect(edit, &QPlainTextEdit::textChanged, [edit, slider](){
      		int v = 0;
      		try {
      			v = std::stoi(edit->toPlainText().toStdString());
      		} catch (...) {}
      		std::cout << "onEditEditingFinished(): " << v << std::endl;
      		slider->blockSignals(true);
      		slider->setValue(v);
      		slider->blockSignals(false);
      	});	
              dlg.show();
              return app.exec();
      }
      
      

       

      The screenshot when issue occurs (on Monterey), the slider range 0-100, I changed text to 75, but slider never repaints.

       

       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            nexu Neil Xu
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes