It is about time for another charm. By charm here, I mean something that you can cast to your existing code (e.g. without changing the class implementation) to get new magical functionalities. You saw the Flick Charm before, as an example.
Today we uncover the secret to make a window (usually the top-level widget) movable by mouse dragging. This trick is employed for example in applications which have custom window decoration, like Apple iTunes or Google Chrome. In these applications, the title bar is not the actual native title bar from the window system. Yet you can "grab" it and use it to move the window around. You may encounter similar behavior in many different web widgets (not in the sense of QWidget), be it Dashboard widgets, Microsoft gadgets, plasmoids, Google gadgets, and so on.
The secret is of course by (ab)using the event filter. Thus, making your window movable-by-dragging is a matter of writing the code:
(At the risk of repeating myself, no code for window needs to be touched).
Any mouse events will be monitored and if they indicate the dragging, the window will be repositioned appropriately. Of course, the trick here is to apply the charm to the top-level window which serves as the outermost frame of your application. A wrong way to use it is e.g. instantiating a QWebView instance and applying there, because now the mouse can't be used to scroll or select text.
Download the latest release here: www.qt.io/download.
Qt 5.15 was developed with a strong focus on quality and is a long-term-supported (LTS) release that will be supported for 3 years.
Check out all our open positions here and follow us on Instagram to see what it's like to be #QtPeople.
Näytä tämä julkaisu Instagramissa.
Want to build something for tomorrow, join #QtPeople today! We have loads of cool jobs you don’t want to miss! http://qt.io/careers #builtwithQt #software #developers #coding #framework #tool #tooling #C++ #QML #engineers #sales #tech #technology #UI #UX #CX #Qt #Qtdev #global #openpositions #careers #job
Henkilön Qt (@theqtcompany) jakama julkaisu