[Interest] Custom-shaped QDialog or similar
Shawn.Rutledge at digia.com
Tue May 21 08:39:22 CEST 2013
On 21 May 2013, at 8:20 AM, Rutledge Shawn wrote:
> On 17 May 2013, at 4:19 PM, Sensei wrote:
>> Dear all,
>> I'd like to try something new for an application: having a custom shaped dialog for some options. You can see my desire in the attachment.
>> Now, what do you suggest to do that? I am lost here!
>> Using a QDialog maybe? But how can I position it exactly where I'd like? Should this be modal? I'd say no: if a user clicks elsewhere, it should disappear, probably.
>> It's the first time I'm trying something like this, so any suggestion is more than welcome!
> If you are using a Mac, that kind of window is called a popover. We don't have support for it yet in Qt, but it should be in Qt::WindowFlags eventually (but only on the Mac).
> Yes you can fake it with Qt Quick, and you could draw the outline with the Canvas API, but probably it's easier to use BorderImage because of the shadows. See qtdeclarative/examples/quick/imageelements/content/ShadowRectangle.qml for example, but you will need an image with the pointy part already done. Make it as wide as the maximum-width popover you will ever want, so you can use horizontalTileMode: BorderImage.Repeat without ever repeating the pointy part. The height won't matter as much. If the popovers sometimes go upwards then you might need two different images.
> Since the pointy part is always inside another window, you don't necessarily need a shaped window for the popover, but a separate Window will allow the popover to extend outside the main window if necessary. Maybe use a QtQuick Window, set color: "transparent" and then provide the frame yourself with BorderImage? Later on you can remove that and set the new window flag when it's working.
But since this is a bit complex I'm beginning to wonder if we should provide a reusable Popover in QtQuick.Dialogs.
More information about the Interest