Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. QToolButton menu is stuck on the main screen, while application is on second screen.

QToolButton menu is stuck on the main screen, while application is on second screen.

Scheduled Pinned Locked Moved Solved Qt for Python
qt for python
3 Posts 2 Posters 744 Views 1 Watching
  • 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.
  • Freemantle01F Offline
    Freemantle01F Offline
    Freemantle01
    wrote on last edited by Freemantle01
    #1

    Hello.

    I'm using two monitors. I notice that when my application is on second screen and I click on QToolButton which contains menu, menu shows on main screen. I tried many things to prevent this but i failed.

    PyQt5=5.15.0

    Does anyone have idea how to fix this?

    I found that someone reported the issue for c++ QTBUG-85012.

    import sys
    
    from PyQt5.QtCore import Qt
    from PyQt5.QtWidgets import QApplication, QMainWindow, QToolButton, QStyle, QWidget, QMenu, QAction
    
    if __name__ == '__main__':
        app = QApplication([])
        window = QMainWindow()
        window.setMinimumSize(600, 400)
        window.setCentralWidget(QWidget())
    
        toolbar = window.addToolBar("tool")
    
        tool_button = QToolButton(toolbar)
        tool_button.setText("Tool button.")
        tool_button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
        tool_button.setIcon(window.style().standardIcon(QStyle.SP_DialogApplyButton))
    
        menu = QMenu(window)
        first_action = QAction(window.style().standardIcon(QStyle.SP_ArrowRight), "Option_1", )
        first_action.triggered.connect(lambda: print("Option_1"))
        second_action = QAction(window.style().standardIcon(QStyle.SP_ArrowLeft), "Option_2")
        second_action.triggered.connect(lambda: print("Option_2"))
        menu.addAction(first_action)
        menu.addAction(second_action)
        tool_button.setMenu(menu)
        tool_button.setPopupMode(QToolButton.InstantPopup)
    
        toolbar.addWidget(tool_button)
        toolbar.setMovable(False)
        toolbar.setFloatable(False)
    
        window.show()
        sys.exit(app.exec_())
    

    Adnotacja 2020-08-10 133710.jpg

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Base on the report, it seems to be a regression so it looks like you should use Qt 5.14.2.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      Freemantle01F 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi and welcome to devnet,

        Base on the report, it seems to be a regression so it looks like you should use Qt 5.14.2.

        Freemantle01F Offline
        Freemantle01F Offline
        Freemantle01
        wrote on last edited by
        #3

        @SGaist said in QToolButton menu is stuck on the main screen, while application is on second screen.:

        Hi and welcome to devnet,

        Base on the report, it seems to be a regression so it looks like you should use Qt 5.14.2.

        Thanks for answer, It's working.

        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