简体   繁体   English

QWebEngineView中央小部件时如何在QWebEngineView之上制作QFrame

[英]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.我正在制作一个无框 window 因为我想在我的 web 浏览器上制作像 Chrome 一样的标签,我搜索了,我需要制作无框 Window 我需要放在它上面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.当它是一个中央小部件时,我不知道如何将它放在 QtWebEngineView 的顶部,当我尝试它不是一个中央小部件并且它与布局一起时,它会在它周围形成一个边框。

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:要删除间距,请将布局边距设置为 0:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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