如何将Button_SetElevationRequiredState与QPushButton一起使用
How to use Button_SetElevationRequiredState with QPushButton?
我试过这个:
QPushButton* openHostsPushButton = new QPushButton("Open Hosts");
Button_SetElevationRequiredState(openHostsPushButton->winId(), true);
openHostsPushButton->setMaximumSize(aPushButtonMaxSize);
connect(openHostsPushButton, SIGNAL(clicked()),
this, SLOT(openHostsClicked()));
但是没有起作用。
我不确定这是否可行,因为Qt实际上并不使用本机控件,而是自定义绘制所有内容。Windows将该图标放置在按钮上的唯一方法是,如果您使用具有类Button
的窗口,则需要窗口管理器为您创建该类。
还要注意的是,为了实现这一点,您必须在应用程序中包含一个清单,以链接到通用控件的版本6(Comctl32.dll),但如果您支持Windows Vista和7,您可能已经在这样做了。
但使用涉及QStyle
:的Qt有一种更简单的方法
QIcon shieldIcon = QApplication::style()->standardIcon(QStyle::SP_VistaShield);
openHostsPushButton->setIcon(shieldIcon);
在不支持UAC的系统上,图标将不会出现。
相关文章:
- 如何将enable-if与模板参数和参数包一起使用
- 如何将PERF_AMPLE_READ与mmap一起使用
- 如何将两个不同矢量的同一位置的两个元素组合在一起
- 如何将C++中的库和头与MinGW一起使用
- 将--whole archive链接器选项与CMake和具有其他库依赖项的库一起使用
- 为什么我不能将 rand() 与数组的大小一起使用?
- 要与"if constexpr"一起使用的编译时消息(在预处理器之后)
- 不能将复制初始化与隐式转换的多个步骤一起使用
- 将fold表达式与std::一起用于两个元组
- spdlog标头仅与外部fmt一起使用.spdlog错误:'内部':不是'fmt'
- 将 std::allocate_shared 与多态资源分配器一起使用
- 为什么常量词在重载运算符中不与 ostream 对象一起使用<<?
- 将 OpenCV 与 CMAKE 中的项目一起构建为第三方库的正确方法
- 将 exprtk 与自定义类的对象一起使用
- 将 std::set 与基于键的比较器一起使用
- 将 C++ 类与 Rcpp 一起使用,从 C 或 R 修改它
- 如何将 Eigen::Ref 与 pybind11 一起使用?
- 如何将AERT_Allocate与 std:vector 一起使用
- 如何使我的 sizeof sum 结构与空参数包一起工作
- 如何将Button_SetElevationRequiredState与QPushButton一起使用