How do I use QLPreviewPanel
? I know it wasn't a public API before, but it is in 10.6. How can I use it to show a preview of a file in a standard QuickLook panel?
Check out the QuickLookDownloader code. It walks you through a couple of things you need to do to incorporate QLPreviewPanel
into your code. Some of these include:
QLPreviewItem
protocol - this tells Quick Look where to find the file you want to preview (and you are previewing files - you can't pass in custom data).QLPreviewPanel
(if you're worked with NSTableView
s before, this should be pretty familiar).QLPreviewPanelController
protocol (where you assign the data source and delegate).Items 1-3 are handled in the MyDocument
class of the sample code. Toggling the display is mostly handled in the AppDelegate
class. There's also support in the DownloadsTableView
class that toggles the QLPreviewPanel
via the space key, a la the Finder.
Sadly Apples QuickLookDownloader Demo uses Obj-C. I extended Josh's Demo with a show panel functionality to show how it is done in Swift: Panel and Popover example
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With