简体   繁体   中英

How to make QFrame on top of QWebEngineView when is QWebEngineView central widget

I'm making a frameless window because I want to make tabs like in Chrome on my web browser and I searched and I need to make Frameless Window I have that and for next, I need to place a QFrame on top of it.And I don't know how to place it on top of QtWebEngineView when it is a central widget and when I try it when it is not a central widget and it is with the layout it makes a border around it.

class MainWindow(QMainWindow):
    def __init__(self, *args, **kwargs):

        super(MainWindow,self).__init__(*args, **kwargs)


        self.setWindowTitle("New Tab")
        self.setWindowIcon(QIcon("browserIcon.ico"))

        self.browser = QWebEngineView()
        self.browser.load(QUrl("https://www.google.com"))

        self.browser.settings().setAttribute(QWebEngineSettings.JavascriptCanOpenWindows, True)
        self.browser.settings().setAttribute(QWebEngineSettings.JavascriptEnabled, True)
        self.browser.settings().setAttribute(QWebEngineSettings.PluginsEnabled, True)
        self.browser.settings().setAttribute(QWebEngineSettings.LocalStorageEnabled, True)
        self.browser.settings().setAttribute(QWebEngineSettings.AutoLoadImages, True)
        self.browser.settings().setAttribute(QWebEngineSettings.AutoLoadIconsForPage, True)
        self.browser.settings().setAttribute(QWebEngineSettings.FullScreenSupportEnabled, True)

        self.browser.page().fullScreenRequested.connect(self.fullScreen)

        self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
        self.setCentralWidget(self.browser)

Create a vertical layout. To remove the spacing set the layout margine to 0:

self.verticalLayout.setContentsMargin(0, 0, 0, 0) 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM