Search code examples
pythonpyqt4qtoolbar

How to get coordinates of QToolBar icons in PyQt4 application?


I'd like to know how to set position of QCalendarWidget just below the button of ToolBar.

Currently, when user clicks a icon button inside red box, enter image description here

then the below Calendar() instance is created and the instance is shown in the middle of screen.

enter image description here

What I want to implement is like the following.

enter image description here

You can refer full source code from here.

Any suggestion or advice will be appreciated.


Solution

  • This functionality is already provided by QDateTimeEdit, so you don't need a separate button for it:

        def init_toolbar(self):
            ...
            dtedit = QtGui.QDateTimeEdit()
            dtedit.setCalendarPopup(True)
    

    Qt Docs: QDateTimeEdit.setCalendarPopup.