Hello!
There are two widgets - parent (main window) and child (pop-up menu):
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
def __init__(self):
self.menu = Menu(parent=self)
self.menu.hide()
...
def __init__(self, parent):
...
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
class Window(QWidget):
def __init__(self):
QWidget.__init__(self)
self.menu = Menu(parent=self)
self.menu.hide()
...
class Menu(QWidget):
def __init__(self, parent):
QWidget.__init__(self, parent)
...
To copy to clipboard, switch view to plain text mode
By default, menu is hidden. The menu should be shown when touch on the main window area. This task is easily solved with QEvent.TouchBegin:
def eventFilter(self, obj, event):
if event.
type() == QEvent.
TouchBegin: self.
menu.
show()
def eventFilter(self, obj, event):
if event.type() == QEvent.TouchBegin: self.menu.show()
To copy to clipboard, switch view to plain text mode
The menu should become hidden when touch on any area of the main window that doesn't have a menu above it (a touch outside the menu).
Is there an easy way to detect this event (without using touch coordinates)?
Bookmarks