You will see I have this code to generate a program without borders in PyQt5 the problem is in the menu bar.
The first thing I tried was to directly load the main menu with the menuBar () function, but I can not accommodate the close, minimize and maximize buttons in the typical location of a window.
And in this example I did it with a frame and inside the frame load the buttons and program them with the functions (close, maximized, etc). But the problem is that the frame remains the same size and does not grow at the same time as the mainWindow.
Some solution:
from PyQt5.QtWidgets import QMainWindow, QApplication,QMenuBar
from PyQt5 import uic
from PyQt5.QtCore import Qt
import sys
class Main(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
uic.loadUi("1.ui",self)
self.setWindowFlags((Qt.FramelessWindowHint))
#Boton de cerrado
self.bclose.clicked.connect(self.close)
#Frame superior que actua como menu
self.f1
#Boton de archivo
self.Archivo
def mousePressEvent(self,event):
if event.button() == Qt.LeftButton:
self.dragPosition = event.globalPos() - self.frameGeometry().topLeft()
event.accept()
def mouseMoveEvent(self,event):
if event.buttons() == Qt.LeftButton:
self.move(event.globalPos() - self.dragPosition)
event.accept()
app = QApplication([])
d = Main()
d.show()
app.exec_()