// main.cpp
#include <QtGui>
{
public:
{
opt.state = 0;
opt.text = "Disabled";
opt.
rect = QRect(0,
0,
100,
25);
style
()->drawControl
(QStyle::CE_PushButton,
&opt,
&painter,
this);
opt.
state = QStyle::State_Enabled;
opt.text = "Enabled";
opt.
rect = QRect(100,
0,
100,
25);
style
()->drawControl
(QStyle::CE_PushButton,
&opt,
&painter,
this);
opt.
state = QStyle::State_Sunken;
opt.text = "Disabled,Sunken";
opt.
rect = QRect(0,
25,
100,
25);
style
()->drawControl
(QStyle::CE_PushButton,
&opt,
&painter,
this);
opt.
state = QStyle::State_Enabled|QStyle
::State_Sunken;
opt.text = "Enabled,Sunken";
opt.
rect = QRect(100,
25,
100,
25);
style
()->drawControl
(QStyle::CE_PushButton,
&opt,
&painter,
this);
}
};
int main(int argc, char* argv[])
{
Widget w;
w.show();
return a.exec();
}
// main.cpp
#include <QtGui>
class Widget : public QWidget
{
public:
void paintEvent(QPaintEvent*)
{
QPainter painter(this);
QStyleOptionButton opt;
opt.state = 0;
opt.text = "Disabled";
opt.rect = QRect(0,0,100,25);
style()->drawControl(QStyle::CE_PushButton, &opt, &painter, this);
opt.state = QStyle::State_Enabled;
opt.text = "Enabled";
opt.rect = QRect(100,0,100,25);
style()->drawControl(QStyle::CE_PushButton, &opt, &painter, this);
opt.state = QStyle::State_Sunken;
opt.text = "Disabled,Sunken";
opt.rect = QRect(0,25,100,25);
style()->drawControl(QStyle::CE_PushButton, &opt, &painter, this);
opt.state = QStyle::State_Enabled|QStyle::State_Sunken;
opt.text = "Enabled,Sunken";
opt.rect = QRect(100,25,100,25);
style()->drawControl(QStyle::CE_PushButton, &opt, &painter, this);
}
};
int main(int argc, char* argv[])
{
QApplication a(argc, argv);
Widget w;
w.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks