C++ 如何将Button_SetElevationRequiredState与QPushButton一起使用?
我试过这个:C++ 如何将Button_SetElevationRequiredState与QPushButton一起使用?,c++,windows,qt,winapi,C++,Windows,Qt,Winapi,我试过这个: QPushButton* openHostsPushButton = new QPushButton("Open Hosts"); Button_SetElevationRequiredState(openHostsPushButton->winId(), true); openHostsPushButton->setMaximumSize(aPushButtonMaxSize); connect(openHostsPushButton, SIGNAL(clicked(
QPushButton* openHostsPushButton = new QPushButton("Open Hosts");
Button_SetElevationRequiredState(openHostsPushButton->winId(), true);
openHostsPushButton->setMaximumSize(aPushButtonMaxSize);
connect(openHostsPushButton, SIGNAL(clicked()),
this, SLOT(openHostsClicked()));
但是没有起作用。我不确定这是否会起作用,因为Qt实际上并不使用本机控件,而是自定义绘制所有内容。Windows将该图标放置在按钮上的唯一方法是使用带有类
按钮的窗口,这是您要求窗口管理器为您创建的
还要注意的是,为了使其正常工作,您必须在应用程序中包含一个清单,以链接到通用控件(Comctl32.dll)的版本6,但如果您支持Windows Vista和7,您可能已经这样做了
但使用Qt有一种更简单的方法:
在不支持UAC的系统上,图标将不会出现。setIcon()
很好,但是否有方法从windows按钮创建QPushButton?
QIcon shieldIcon = QApplication::style()->standardIcon(QStyle::SP_VistaShield);
openHostsPushButton->setIcon(shieldIcon);