Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何为应用程序中的某些按钮重置QApplication::样式表?_C++_Qt_Qt5_Qtstylesheets - Fatal编程技术网

C++ 如何为应用程序中的某些按钮重置QApplication::样式表?

C++ 如何为应用程序中的某些按钮重置QApplication::样式表?,c++,qt,qt5,qtstylesheets,C++,Qt,Qt5,Qtstylesheets,在main()函数中,我在应用程序的所有按钮上设置样式表 qApp->setStyleSheet("QPushButton {" " border: 1px solid #8f8f91;" " border-radius: 4px;" " background-color: qlineargradie

在main()函数中,我在应用程序的所有按钮上设置样式表

qApp->setStyleSheet("QPushButton {"
                            "     border: 1px solid #8f8f91;"
                            "     border-radius: 4px;"
                            "     background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #f6f7fa, stop: 1 #dadbde);"
                            "     padding: 3px;"
                            " }");
但是现在我需要重置一些按钮的样式。我尝试了
按钮->设置样式表(“”
),但它不起作用。那么,如何做到这一点呢?

你不能

您可以做的恰恰相反,即设置某些按钮的样式表,如下所示:

qApp->setStyleSheet("QPushButton[specialButton=\"true\"] {"
                    "     border: 1px solid #8f8f91;"
                    "     border-radius: 4px;"
                    "     background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #f6f7fa, stop: 1 #dadbde);"
                    "     padding: 3px;"
                    "}");
然后:

button->setProperty("specialButton", true);
这样,只有将specialButton设置为
true
的按钮才具有自定义外观,其他按钮看起来正常。

您不能

您可以做的恰恰相反,即设置某些按钮的样式表,如下所示:

qApp->setStyleSheet("QPushButton[specialButton=\"true\"] {"
                    "     border: 1px solid #8f8f91;"
                    "     border-radius: 4px;"
                    "     background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #f6f7fa, stop: 1 #dadbde);"
                    "     padding: 3px;"
                    "}");
然后:

button->setProperty("specialButton", true);
这样,只有specialButton设置为
true
的按钮才具有自定义外观,其他按钮看起来正常