summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets/code/src_gui_qproxystyle.cpp
blob: a9c55b3048500f0b3dd6c61cdeb4b86ccdd6e207 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//! [0]
class MyProxyStyle : public QProxyStyle
{
public:

    int styleHint(StyleHint hint, const QStyleOption *option = 0, 
                  const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const
    {
        if (hint == QStyle::SH_UnderlineShortcut)
            return 1;
        return QProxyStyle::styleHint(hint, option, widget, returnData);
    }
};

//! [0]

//! [1]
#include "textedit.h"
#include <QApplication>
#include <QProxyStyle>
  
class MyProxyStyle : public QProxyStyle
{
  public:
    int styleHint(StyleHint hint, const QStyleOption *option = 0,
                  const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const
    {
        if (hint == QStyle::SH_UnderlineShortcut)
            return 0;
        return QProxyStyle::styleHint(hint, option, widget, returnData);
    }
};
    
int main(int argc, char **argv)
{
    Q_INIT_RESOURCE(textedit);
    
    QApplication a(argc, argv);
    a.setStyle(new MyProxyStyle);
    TextEdit mw;
    mw.resize(700, 800);
    mw.show(); 
    //...
}
//! [1]