QWebView does not decompose correctly

Even if I set the geometry for QWebView, it takes up the whole screen on the left.

alt text Even worse, if I maximize the window, there is a space between the two widgets

alt text Below I wrote my code:

from PyQt4.QtGui import *
from PyQt4.QtCore import *
from PyQt4.QtWebKit import *

class twsearchbox(QWidget):
    def __init__(self):
        QWidget.__init__(self)
        hbx = QHBoxLayout()        
        self.setLayout(hbx)
        self.resize(1024,800)
        self.setWindowTitle('layout test')

        tbx = QTextEdit()
        tbx.setGeometry(0,0, 300, 550)
        tbx.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding)
        hbx.addWidget(tbx, 0 , Qt.AlignLeft)

        wv = QWebView()
        wv.load(QUrl('twsearch_template.html'))
        wv.setGeometry(0,0,300,550)
        wv.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding)
        hbx.addWidget(wv, 0 , Qt.AlignLeft)
+3
source share
2 answers

I researched this in code (in C ++) and found it a little perplexing until, finally, I looked at the source code for QWebView. It seems to be QWebView::sizeHint()hardcoded up to 800 x 600 (Qt 4.6).

This seems a little strange to me, but I'm not sure to report an error. If someone can post a comment to confirm or deny it is correct, that would be nice :)

, / / .

, , , QWebView (300), , . QWebView 800, , , . , , , , , .

0

, , http://doc.qt.nokia.com/latest/qboxlayout.html#setStretch

QSeeView sizepolicy

webView- > setSizePolicy (QSizePolicy:: Expanding, QSizePolicy:: );

0

Source: https://habr.com/ru/post/1769934/


All Articles