Попробуйте:
main.py
import sys
#from PySide2 import QtWidgets, QtCore, QtGui
from PyQt5 import QtWidgets, QtCore, QtGui
from select_company_controller import SelectCompany
#from views.main_window_view import MainWindowForm
class MainWindow(QtWidgets.QMainWindow): #, MainWindowForm):
def __init__(self):
super(MainWindow, self).__init__()
# self.setupUi(self)
self.setWindowTitle('Main Window')
centralWidget = QtWidgets.QWidget()
self.setCentralWidget(centralWidget)
button = QtWidgets.QPushButton('Open SelectCompany')
button.clicked.connect(self.open_select_company_window)
grid = QtWidgets.QGridLayout(centralWidget)
grid.addWidget(button)
def open_select_company_window(self):
self.window = SelectCompany(self)
self.window.show()
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
w = MainWindow()
w.show() #showMaximized()
sys.exit(app.exec_())
select_company_controller.py
#from PySide2 import QtWidgets, QtCore, QtGui
from PyQt5 import QtWidgets, QtCore, QtGui
#from views.select_company_view import SelectCompanyForm
class SelectCompany(QtWidgets.QMainWindow): #QWidget, SelectCompanyForm):
def __init__(self, parent=None):
super(SelectCompany, self).__init__(parent)
self.parent = parent
self.setWindowTitle('SelectCompany')
centralWidget = QtWidgets.QWidget()
self.setCentralWidget(centralWidget)
button = QtWidgets.QPushButton('Close MainWindow')
button.clicked.connect(self.close_main_window)
grid = QtWidgets.QGridLayout(centralWidget)
grid.addWidget(button)
def close_main_window(self):
self.parent.hide()
Обновление
#from PySide2 import QtWidgets, QtCore, QtGui
from PyQt5 import QtWidgets, QtCore, QtGui
#from views.select_company_view import SelectCompanyForm
class SelectCompany(QtWidgets.QWidget): #, SelectCompanyForm): # <--- QWidget
def __init__(self, parent=None):
super(SelectCompany, self).__init__(parent)
self.parent = parent
self.setWindowFlags(QtCore.Qt.Window | QtCore.Qt.WindowStaysOnTopHint) # <---
self.setWindowTitle('SelectCompany')
button = QtWidgets.QPushButton('Close MainWindow')
button.clicked.connect(self.close_main_window)
grid = QtWidgets.QGridLayout(self)
grid.addWidget(button)
def close_main_window(self):
self.parent.hide()