how to combine 2 progressbar widgets into one widget when the user drags and drops to one of the widgets? MainWindowHide window must always be hidden and only used for progressbar initiation. I want widgets to be able to be dragged and dropped like chrome tabs and can be separated again. Thank you for your help.
this is my code:
import sys
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QMainWindow
class Widget_Progressbar(QtWidgets.QWidget):
def __init__(self, parent=None):
super(Widget_Progressbar, self).__init__(parent)
self.setWindowTitle("Progress Bar")
self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
self.setGeometry(500, 500, 680, 80)
self.progressBar = QtWidgets.QProgressBar(self)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.progressBar.sizePolicy().hasHeightForWidth())
self.progressBar.setSizePolicy(sizePolicy)
font = QtGui.QFont()
font.setPointSize(8)
self.progressBar.setFont(font)
self.progressBar.setOrientation(QtCore.Qt.Horizontal)
self.progressBar.setTextDirection(QtWidgets.QProgressBar.TopToBottom)
self.progressBar.setAlignment(QtCore.Qt.AlignCenter)
self.gridLayout = QtWidgets.QGridLayout(self)
self.gridLayout.setObjectName("gridLayout")
self.gridLayout.addWidget(self.progressBar, 0, 0, 1, 1)
self.progressBar.setValue(50)
class MainWindowHide(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("Hide Main Window")
self.setGeometry(100, 100, 800, 600)
self.widgetprogressbar = Widget_Progressbar()
self.widgetprogressbar.show()
self.widgetprogressbar2 = Widget_Progressbar()
self.widgetprogressbar2.show()
def closeEvent(self, event):
self.widgetprogressbar.close()
event.accept()
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
win = MainWindowHide()
sys.exit(app.exec_())
moveEvent()of the widget, that wouldn't be completely reliable, as window movements are not always opaque on some configurations. This means that the only way to achieve this by implementing the movement of the window on your own (possibly with a custom title bar) and then detect if the current geometry may collide with the geometry of the other widgets. Since this implementation is a bit complex and has to be written from scratch, I doubt you'll get any answer for it, so I suggest you to look into what explained above and attempt to do it on your own, then if »