This property specifies whether consecutive separators in the menu should be visually collapsed to a single one. This property holds whether consecutive separators should be collapsed. setSeparatorsCollapsible ( collapse ) ¶ Parameters : īy default, if no icon is explicitly set, this property contains a null icon. This is equivalent to the icon property of the menuAction(). This property holds The icon of the menu. If the QWidgetAction fires the triggered() signal, the menu will close.ĭefaultAction(). Instances of this class are used to hold widgets, and are inserted into menus with the addAction() overload that takes a QAction. Widgets can be inserted into menus with the QWidgetAction class. When using tear-off menus, bear in mind that the concept isn’t typically used on Microsoft Windows so some users may not be familiar with it. If you want this functionality for a particular menu, insert a tear-off handle with setTearOffEnabled(). This makes it possible for the user to “tear off” frequently used menus and position them in a convenient place on the screen. A tear-off menu is a top-level window that contains a copy of the menu. Ī QMenu can also provide a tear-off menu. You clear a menu with clear() and remove individual action items with removeAction(). In addition, QMenu provides two signals, triggered() and hovered(), which signal the QAction that was triggered from the menu. The receiver will be notified whenever the item is triggered(). When inserting action items you usually specify a receiver and a slot. Separators are inserted with addSeparator(), submenus with addMenu(), and all other items are considered action items. There are four kinds of action items: separators, actions that show a submenu, widgets, and actions that perform an action. The existing actions held by a menu can be found with actions(). In addition, actions can have a text label, an optional icon drawn on the very left side, and shortcut key sequence such as “Ctrl+X”. An action is represented vertically and rendered by QStyle. Actions are added with the addAction(), addActions() and insertAction() functions. ()ĭef addAction (arg_1, arg_2, arg_3)ĭef addAction (arg_1, arg_2)ĭef addAction (icon, text, receiver, member)ĭef addAction (text, receiver, member)Ī menu consists of a list of action items.QMenu on macOS with Qt Build Against Cocoa.Shortcut = QShortcut(key_sq, qwindow, pie_menu. If isinstance(c, QShortcut) and (c.key() = key_sq): Key_sq = QKeySequence(Qt.CTRL + Qt.Key_Space) # old_override = QGuiApplication.overrideCursor() Offset = QPoint(half_size.width(), half_size.height()) # tMask(self.create_mask_from_buttons())Ĭreate mask from buttons, so that gaps inīetween buttons are transparent to inputs.īutton = QPushButton(f'button_', parent=self) tAutoFillBackground(False) # just to be sure tAttribute(Qt.WA_TranslucentBackground, True) Super()._init_(parent, Qt.Popup | Qt.NoDropShadowWindowHint | Qt.FramelessWindowHint) QMenu.exec_() would show window in modal state at given position. Override layout of child QToolButtons (one for each QAction in menu) Maybe this gives some new ideas? from PyQt5.QtCore import ( There are some issues on how to create transparent window on all platforms, but it should be easier than trying to define exact draw z-order of all children of main window. And note that child widgets that don’t have own window are always cropped to parent widgets window, resizing of main window at border areas just so that popup menu can draw it self without cropping, or use off-center origin in pie menu? It’s really normal to create floating windows a top of parent widget, just to get correct z-order (QComboBox, QMenu, QToolTip …). So it would best to keep pie popup menu as pie popup window that is parented to main window. Normally Qt parents don’t want to define top child among children, and editing children list order is BIG no no.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |