Qt Windows Extras 提供使您能够使用各种 Windows 特定函数的类和函数。例如:可以将 Qt 对象转换成 Windows 对象句柄和操纵 DWM (桌面窗口管理器) 玻璃框。
此外,可以使用 Windows 7 引入的特征,譬如 Aero Peek、跳转列表、任务栏按钮进度指示器或缩略工具栏。
The QtWin 名称空间提供函数来转换 Qt 类对象,譬如 QPixmap or QImage 成 Windows HBITMAP 或 HICON 句柄,反之亦然。
可以确定窗口是否包括在 DWM (桌面窗口管理器) Flip3D 渲染中。
可以轻松操纵 Windows Vista 首次引入的玻璃框,使用 QtWin::extendFrameIntoClientArea () 和 QtWin::enableBlurBehindWindow () functions. Windows 8 lost the glass effect, but applications can still integrate their windows into the system frame to visually separate window controls from the rest of the window or to focus the user's attention on window content.
Windows 7 Aero Peek feature gives the users the powers of X-ray vision that enable them to peek past all open windows straight at the desktop and the gadgets placed there. They can view the contents of a window without actually switching to it. You can enable Aero Peek for a gadget-like window or for a window that constantly displays monitoring data.
可以使用 QtWin::setWindowExcludedFromPeek () 函数以排除 Aero Peek 应用程序窗口。
注意: 默认情况下,Aero Peek 在 Windows 8 中是被禁用的,但用户可以启用。
The taskbar provides users with access to applications that are open on the desktop. Windows automatically creates buttons on the taskbar for accessing application windows. Windows 7 adds new features to the taskbar buttons that are discussed in the following sections.
可以使用 QWinTaskbarButton class to set an overlay icon and the QWinTaskbarProgress class to display a progress indicator on a taskbar button. An overlay icon indicates change in the state of the application. A progress indicator shows how time-consuming tasks are progressing.
以下范例代码阐明如何使用 QWinTaskbarButton and QWinTaskbarProgress 类去调节任务栏按钮的外观:
QWinTaskbarButton *button = new QWinTaskbarButton(widget); button->setWindow(widget->windowHandle()); button->setOverlayIcon(QIcon(":/loading.png")); QWinTaskbarProgress *progress = button->progress(); progress->setVisible(true); progress->setValue(50);
应用程序可以使用跳转列表为用户提供对文件的更快访问,或显示任务或命令的快捷方式。
注意: To be able to add destinations to its Jump Lists, the application should associate itself with the file types it can handle.
The following example code illustrates how to use the classes in the QWinJumpList and QWinJumpListItem classes to implement Jump Lists:
QWinJumpList jumplist; jumplist.begin(); jumplist.setKnownCategoryShown(QWinJumpList::RecentCategory); jumplist.beginTasks(); QWinJumpListItem *newProject = new QWinJumpListItem(QWinJumpListItem::Link); newProject->setTitle(tr("Create new project")); newProject->setFilePath(QDir::toNativeSeparators(QCoreApplication::applicationFilePath())); newProject->setArguments(QStringList("--new-project")); jumplist.addItem(newProject); jumplist.addLink(tr("Launch SDK Manager"), QDir::toNativeSeparators(QCoreApplication::applicationDirPath()) + "\\sdk-manager.exe"); jumplist.commit();
Applications can embed a toolbar in the thumbnail of a window, which is shown when hovering over its taskbar icon. A thumbnail toolbar may provide quick access to the window's commands without requiring the user to restore or activate the window.
The following example code illustrates how to use the functions in the QWinThumbnailToolBar and QWinThumbnailToolButton 类以实现缩略图工具栏:
QWinThumbnailToolBar *thumbbar = new QWinThumbnailToolBar(widget); thumbbar->setWindow(widget->windowHandle()); QWinThumbnailToolButton *settings = new QWinThumbnailToolButton(thumbbar); settings->setToolTip("Settings"); settings->setIcon(":/settings.png"); settings->setDismissOnClick(true); connect(settings, SIGNAL(clicked()), settingsPage, SLOT(show())); QWinThumbnailToolButton *playPause = new QWinThumbnailToolButton(thumbbar); playPause->setToolTip("Play/Pause"); playPause->setIcon(":/play.png"); connect(playPause, SIGNAL(clicked()), mediaPlayer, SLOT(play())); thumbbar->addButton(settings); thumbbar->addButton(playPause);