Reputation: 283
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,
then the below Calendar() instance is created and the instance is shown in the middle of screen.
What I want to implement is like the following.
You can refer full source code from here.
Any suggestion or advice will be appreciated.
Upvotes: 1
Views: 276
Reputation: 120578
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.
Upvotes: 2
Reputation: 37499
This is usually done with a combination of using QWidget.geometry()
or QWidget.rect()
to get the size and position of a widget (in this case, the clicked button) and then using the QWidget.mapFromXXX
and QWidget.mapToXXX
series of functions, to transform those into global coordinates and then into widget coordinates that can be fed to QWidget.move()
Upvotes: 1