[vtk-developers] Fractional DPI scaling not supported by QVTKOpenGLWidget?

Karsten Tausche karsten.tausche at student.hpi.uni-potsdam.de
Fri Feb 9 04:31:16 EST 2018


Hi Elvis,

I have a workaround for this in my own code: Basically I have a subclass 
of QVTKOpenGLWidget, which disables the base class DPI support and 
passes Qt's DPI value manually to the internal vtkRenderWindow. See 
https://github.com/kateyy/geohazardvis/blob/master/gui/data_view/t_QVTKWidget.cpp 
especially lines 288 and 306.

(In the code, don't get confused about the name of the class, it 
provides some support to inherit from QVTKWidget2, but you can assume 
OPTION_USE_QVTKOPENGLWIDGET to be enabled.)

Cheers,
Karsten


On 09-02-18 08:43, Elvis Stansvik wrote:
> Den 5 feb. 2018 3:20 em skrev "Elvis Stansvik" 
> <elvis.stansvik at orexplore.com <mailto:elvis.stansvik at orexplore.com>>:
>
>     Hi all,
>
>     My pointy-haired boss got a new laptop with a high-DPI monitor, and
>     started using a fractional DPI scaling factor (under KDE screen
>     settings). He's now reporting that our Qt/VTK app has problems with
>     this. The VTK windows are not correctly sized.
>
>     I've also gotten the same report from a Windows 10 user that had
>     this problem.
>
>     I had a look at the VTK code that sizes the render window [1]:
>
>       const int devicePixelRatio_ = this->devicePixelRatio();
>       const QSize widgetSize = this->size();
>       const QSize deviceSize = widgetSize * devicePixelRatio_;
>
>     and then
>
>       this->RenderWindow->SetSize(deviceSize.width(),
>     deviceSize.height());
>
>     Note the use of the int devicePixelRatio() API, not qreal
>     devicePixelRatioF() (available from Qt 5.6).
>
>     Does this mean there's no way to get correctly sized VTK windows when
>     using a fractional DPI scaling factor? If so, has anyone looked into
>     supporting this? Would it be a lot of work?
>
>
> Noone knows? :)
>
> If it's (like I suspect) currently not supported, I'd be willing to 
> try to fix it myself. But it would be good to know whether there are 
> dragons here (maybe that's why it's not supported yet) or if someone 
> else is already working on it.
>
> Elvis
>
>
>     Best regards,
>     Elvis
>
>     [1]
>     https://gitlab.kitware.com/vtk/vtk/blob/master/GUISupport/Qt/QVTKOpenGLWidget.cxx#L340-351
>     <https://gitlab.kitware.com/vtk/vtk/blob/master/GUISupport/Qt/QVTKOpenGLWidget.cxx#L340-351>
>
>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Search the list archives at: http://markmail.org/search/?q=vtk-developers
>
> Follow this link to subscribe/unsubscribe:
> https://vtk.org/mailman/listinfo/vtk-developers
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://vtk.org/pipermail/vtk-developers/attachments/20180209/ffd2d686/attachment.html>


More information about the vtk-developers mailing list