尝试以下代码:
<!DOCTYPE html>
<html style="min-width:600px; overflow:auto;">
<body style="background:grey; padding:0px; margin:0px;">
<div style="text-align:right;">
this is some text
</div>
在一个我使用QGLWidget创建自己的图像查看器的项目中,我试图在显示大图像时添加缩放和滚动功能,但我遇到了一个问题,图像被剪切,并且不能比它的原始尺寸或面板尺寸更宽。
在这里,我设置了视口和glScalef。在实现滚动时,我继承了QAbstractScrollArea的子类,并将滚动条的坐标传递给一个变量。
// scrollOffset has the coordinates of horizontal and vertical scrollbars
// this->width() and this->height() are panel size
glViewport(0