Bug 35681

Summary: [Qt] problem with QWebView, Plastique style and scroll bars on OSX
Product: WebKit Reporter: Tor Arne Vestbø <vestbo>
Component: PlatformAssignee: Alexis Menard (darktears) <menard>
Status: RESOLVED DUPLICATE    
Severity: Normal CC: andy_hello_world, menard
Priority: P2 Keywords: Qt, QtTriaged
Version: 528+ (Nightly build)   
Hardware: Other   
OS: OS X 10.5   

Description Tor Arne Vestbø 2010-03-03 07:00:53 PST
This bug report originated from issue QTBUG-3741
http://bugreports.qt.nokia.com/browse/QTBUG-3741

--- Description ---

The following code produce a scroll bar with no handle on OSX

<p>int main(int argc, char *argv[])</p>
{
    QApplication app(argc, argv);
    QWebView wv;
    wv.load(QUrl("http://www.tsr.ch"));
    wv.setStyle(new QPlastiqueStyle());
    wv.show();
    return app.exec();
}
Comment 1 Tor Arne Vestbø 2010-03-15 08:28:35 PDT
Can be reproduced by running the QtLauncher with -style plastique http://www.tsr.ch

Scrollbars are missing the thum, and the clip seems to be broken when resizing the window
Comment 2 Andreas Renz 2010-12-27 14:43:09 PST
I encountered the same problem (scoll bar and scoll bar buttons are not correctly painted for the QWebView). I am using an own Qt Style which is based on QWindowsStyle. 
The ScrollBars are working if you use QWebView with this style (or other styles like QWindowsStyle, QPlastiqueStyle) on a Windows system.
It is not working if you use QWebView and this style (or other styles like QWindowsStyle, QPlastiqueStyle) on a Mac system.
For a Mac systems the only Style offering correct ScrollBars with QWebView seems to be the QMacStyle.


Digging in the code I saw in the file ScrollbarThemeQt.cpp in the method ScrollbarThemeQt::paint() the following code part:

#ifdef Q_WS_MAC
    p.drawComplexControl(QStyle::CC_ScrollBar, *opt);
#else
    const QPoint topLeft = opt->rect.topLeft();
    p.painter->translate(topLeft);
    opt->rect.moveTo(QPoint(0, 0));

    // The QStyle expects the background to be already filled
    p.painter->fillRect(opt->rect, opt->palette.background());

    p.drawComplexControl(QStyle::CC_ScrollBar, *opt);
    opt->rect.moveTo(topLeft);
#endif

So for Mac there is no move of the rectangle to the position (0, 0) and also the coordinate system of the painter is not translated.
For the QMacStyle this seems to be OK (or it doesn't matter), but when using other styles like QWindowsStyle or QPlastiqueStyle then I think they expect also on a Mac system to have the rectangle relative to (0, 0).

As a workaround I have implemented in my own style for the handling of the complex control CC_ScrollBar to check if the given pointer to the widget is a QWebView object (using qobject_cast) and if it is QWebView then it there will be applied the movement of the rectangle and the translation of the painter's coordinate system as shown in the code part above. With this workaround the ScrollBars where painted correctly.

Instead of having a conditional compilation in ScrollbarThemeQt::paint() (see code above Q_WS_MAC) just statically depending on the system platform, it might be a solution if it would be possible to dynamically (at run-time) check which style is active in the ScrollbarThemeQt::paint() and then perform the movement and translation if it is not QMacStyle.
Comment 3 Alexis Menard (darktears) 2011-05-23 12:57:44 PDT

*** This bug has been marked as a duplicate of bug 34635 ***