I am working in PyQT4 with Qt Designer. My goal is to hide the title bar of a widget.
I know there is a method like widget.setWindowFlags
(QtCore.Qt.CustomizeWindowHint
) or widget.setWindowFlags
(QtCore.Qt.FramelessWindowHint
), but it doesn't work in my case.
My widget is a child of QWorkspace
. That means my widget was added to Qworspace
. I am trying to hide the title bar in the same way, but it doesn't work.
Does anybody knows how to remove the program's title bar in this case?
My Code: I tried with both methods. They have been commented out.
Edit:
modul: search.py
from PyQt4.QtGui import QWidget
from PyQt4.uic import loadUi
from PyQt4.QtCore import Qt
class Search_Window(QWidget):
def __init__(self, parent=None):
QWidget.__init__(self, parent, Qt.FramelessWindowHint)
self.getPath_search_ui = os.path.join(os.path.abspath("."), 'files', "qt_ui", 'pp_search.ui')
self.ui_pp_search = loadUi(self.getPath_search_ui, self)
modul: mdi.py
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import os
from PyQt4.QtGui import QMainWindow, QWorkspace
from PyQt4.QtCore import Qt
from PyQt4.uic import loadUi
from ..modules_ui.ui_pp_search import Search_Window
class Mdi_Main(QMainWindow):
def __init__(self, parent=None):
QMainWindow.__init__(self, parent)
self.getPath_mdi = os.path.join(os.path.abspath("."), 'files', "qt_ui", 'pp_mdi.ui')
self.ui_TestMainWorkSpace = loadUi(self.getPath_mdi, self)
self.ui_TestMainWorkSpace.showMaximized()
self.workspace = QWorkspace()
self.workspace.setScrollBarsEnabled(True)
self.setCentralWidget(self.workspace)
def create_action_menu(self):
self.ui_TestMainWorkSpace.actionSearch.triggered.connect(self.show_search_form)
def show_search_form(self):
search_form = Search_Window()
self.workspace.addWindow(search_form, Qt.FramelessWindowHint)
search_form.show()
You can see I try to hide the title bar by adding search_form to workspace. Its also doesn't work.
The following snippet works for me, by specifying the window flags to the addWindow method:
from PyQt4.QtGui import QApplication, QWorkspace, QTableView
from PyQt4.QtCore import Qt
def main():
app = QApplication([])
workspace = QWorkspace()
view = QTableView()
workspace.addWindow(view, Qt.FramelessWindowHint)
workspace.show()
app.exec_()
if __name__ == '__main__':
main()