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

Elvis Stansvik elvis.stansvik at orexplore.com
Fri Feb 9 04:51:23 EST 2018


2018-02-09 10:31 GMT+01:00 Karsten Tausche
<karsten.tausche at student.hpi.uni-potsdam.de>:
> 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.)

Aha, thanks a lot Karsten. I'll see if I can do something similar in
our own QVTKOpenGLWidget subclass.

(Still of course interested in if any of the VTK devs have looked into
supporting this out of the box.)

Elvis

>
> 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>:
>
> 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
>
>
>
>
> _______________________________________________
> 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
>
>
>
> _______________________________________________
> 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
>
>


More information about the vtk-developers mailing list