~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to kchart/kdchart/examples/HeadersFooters/HeadersFootersParameters/main.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-09-21 15:36:35 UTC
  • mfrom: (1.4.1 upstream) (60.2.11 maverick)
  • Revision ID: james.westby@ubuntu.com-20100921153635-6tejqkiro2u21ydi
Tags: 1:2.2.2-0ubuntu3
Add kubuntu_03_fix-crash-on-closing-sqlite-connection-2.2.2.diff and
kubuntu_04_support-large-memo-values-for-msaccess-2.2.2.diff as
recommended by upstream http://kexi-
project.org/wiki/wikiview/index.php@Kexi2.2_Patches.html#sqlite_stab
ility

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <QtGui>
2
 
#include <KDChartChart>
3
 
#include <KDChartBarDiagram>
4
 
#include <KDChartHeaderFooter>
5
 
#include <KDChartPosition>
6
 
#include <KDChartBackgroundAttributes>
7
 
#include <KDChartFrameAttributes>
8
 
 
9
 
using namespace KDChart;
10
 
 
11
 
class ChartWidget : public QWidget {
12
 
  Q_OBJECT
13
 
public:
14
 
  explicit ChartWidget(QWidget* parent=0)
15
 
    : QWidget(parent)
16
 
  {
17
 
 
18
 
    m_model.insertRows( 0, 2, QModelIndex() );
19
 
    m_model.insertColumns(  0,  3,  QModelIndex() );
20
 
    for (int row = 0; row < 3; ++row) {
21
 
            for (int column = 0; column < 3; ++column) {
22
 
                QModelIndex index = m_model.index(row, column, QModelIndex());
23
 
                m_model.setData(index, QVariant(row+1 * column) );
24
 
            }
25
 
    }
26
 
 
27
 
    BarDiagram* diagram = new BarDiagram;
28
 
    diagram->setModel(&m_model);
29
 
 
30
 
    m_chart.coordinatePlane()->replaceDiagram(diagram);
31
 
 
32
 
    // Add at one Header and set it up
33
 
    HeaderFooter* header = new HeaderFooter( &m_chart );
34
 
    header->setPosition( Position::North );
35
 
    header->setText( "A Simple Bar Chart" );
36
 
    m_chart.addHeaderFooter( header );
37
 
 
38
 
    // Configure the Header text attributes
39
 
    TextAttributes hta;
40
 
    hta.setPen( QPen(  Qt::blue ) );
41
 
 
42
 
    // let the header resize itself
43
 
    // together with the widget.
44
 
    // so-called relative size
45
 
    Measure m( 35.0 );
46
 
    m.setRelativeMode( header->autoReferenceArea(), KDChartEnums::MeasureOrientationMinimum );
47
 
    hta.setFontSize( m );
48
 
    // min font size
49
 
    m.setValue( 3.0 );
50
 
    m.setCalculationMode( KDChartEnums::MeasureCalculationModeAbsolute );
51
 
    hta.setMinimalFontSize( m  );
52
 
    header->setTextAttributes( hta );
53
 
 
54
 
    // Configure the header Background attributes
55
 
    BackgroundAttributes hba;
56
 
    hba.setBrush(  Qt::white );
57
 
    hba.setVisible( true );
58
 
    header->setBackgroundAttributes(  hba );
59
 
 
60
 
    // Configure the header Frame attributes
61
 
    FrameAttributes hfa;
62
 
    hfa.setPen( QPen ( QBrush( Qt::darkGray ), 2 ) );
63
 
    hfa.setVisible( true );
64
 
    header->setFrameAttributes(  hfa );
65
 
 
66
 
    QVBoxLayout* l = new QVBoxLayout(this);
67
 
    l->addWidget(&m_chart);
68
 
    m_chart.setGlobalLeadingTop( 10 );
69
 
    setLayout(l);
70
 
  }
71
 
 
72
 
private:
73
 
  Chart m_chart;
74
 
  QStandardItemModel m_model;
75
 
};
76
 
 
77
 
int main( int argc, char** argv ) {
78
 
    QApplication app( argc, argv );
79
 
 
80
 
    ChartWidget w;
81
 
    w.show();
82
 
 
83
 
    return app.exec();
84
 
}
85
 
 
86
 
#include "main.moc"