Details
-
Bug
-
Resolution: Out of scope
-
P3: Somewhat important
-
None
-
5.9.0
-
None
Description
I've found a difference in behaviour of QScrollArea under Mac and under Windows (I haven't tested this on Linux myself, but those who did say that Linux does not suffer from that issue).
I have a QScrollArea that contains several QWidget's each of which contains a QVBoxLayout, that contains a single QPlainTextEdit. I'm trying to scroll the QScrollArea. When the mouse cursor is above the QScrollArea itself everything is fine, the scroll is smooth. When I'm using Windows and the scroll is above a QPlainTextEdit everything is fine too, scroll is still smooth. When I'm using Mac and the cursor is above a QPlainTextEdit the scroll glitches. When the cursor leaves a QPlainTextEdit, it becomes smooth, but when it enters an edit, it glitches again.
It seems that under Mac the edit tries to handle scroll events itself. What can I do to enable smooth scrolling on Mac too?
I captured a short video that illustrates the problem: https://vimeo.com/233367282
Here is my code (used to capture the video):
#include "mainwindow.h" #include "ui_mainwindow.h" #include <QVBoxLayout> #include <QScrollArea> #include <QPlainTextEdit> #include <QWidget> QWidget* createWidget(int id); MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); QVBoxLayout *mainLayout = new QVBoxLayout(); for(int i = 0; i < 60; i++) { auto *w = createWidget(i); mainLayout->addWidget(w); } mainLayout->addStretch(); QWidget *mainWidget = new QWidget(); mainWidget->setLayout(mainLayout); QScrollArea *scrollArea = new QScrollArea(); scrollArea->setWidgetResizable(true); scrollArea->setWidget(mainWidget); setCentralWidget(scrollArea); } MainWindow::~MainWindow() { delete ui; } QWidget* createWidget(int id) { auto w = new QWidget(); auto lay = new QVBoxLayout(w); auto ed = new QPlainTextEdit(); lay->addWidget(ed); lay->setMargin(0); lay->setSpacing(0); ed->setPlainText(QString("%1").arg(id)); if (id % 10 == 0) ed->setMinimumHeight(150); return w; }
Put this code into MainWindow.cpp and leave everything else untouched.
Related topic on Qt forum:
https://forum.qt.io/topic/83195/glitched-scroll-of-qscrollarea