Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QGraphicsProxyWidget undo ItemStacksBehindParent?
Forum Updated to NodeBB v4.3 + New Features

QGraphicsProxyWidget undo ItemStacksBehindParent?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt5pyqt5pyside2qgraphicsitemqgraphicsproxyw
1 Posts 1 Posters 356 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • GofferG Offline
    GofferG Offline
    Goffer
    wrote on last edited by Goffer
    #1

    Hello,
    I'm running into a problem with items / widgets stacking.

    I've:
    QGraphicsItem
    QGraphicsProxyWidget (parented under the QGraphicsItem)
    QTextEdit in the QGraphicsProxyWidget

    By default the QGraphicsProxyWidget has the ItemStacksBehindParent flag so that I cannot see nor interact with the QTextEdit, when double clicking on my QGraphicsItem, I remove the ItemStacksBehindParent flag so that my QTextEdits becomes visible and editable.

    I can see it and it has focus but I cannot type anything in it...

    If I remove the ItemStacksBehindParent flag , I can edit the QTextEdit properly but then I lose my QGraphicsItem behavior... and I need that behavior.

    Any idea why the QTextEdit doesn't work with the flag? I'm sure I'm forgetting something stupid.

    class GraphicsItem(QGraphicsItem):
        def __init__(self):
            super(GraphicsItem, self).__init__()
    
            self.browser = TextBrowser()
            self.editor = TextEdit()
            self.proxy = QtWidgets.QGraphicsProxyWidget(self)
            self.proxy.setWidget(self.browser)
            self.proxy.setFlag(QtWidgets.QGraphicsItem.ItemStacksBehindParent)
            self.displayedWidget = self.browser
    
        def mouseDoubleClickEvent(self, event):
            self.proxy.setFlags(self.flags() & ~self.ItemStacksBehindParent)
            self._swapWidget()
            super(GraphicsItem, self).mouseDoubleClickEvent(event)
    
        def _swapWidget(self):
            if isinstance(self.displayedWidget, QtWidgets.QTextBrowser):
                self.proxy.setWidget(self.editor)
                self.displayedWidget = self.editor
                self.editor.setFocus()
    
            else:
                self.proxy.setWidget(self.browser)
                self.displayedWidget = self.browser
                self.browser.setFocus()
                self.proxy.setFlag(QtWidgets.QGraphicsItem.ItemStacksBehindParent)
    
    

    Thanks!

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved