MCPcopy Create free account
hub / github.com/KDAB/KDChart / MainWindow

Method MainWindow

examples/Bars/Advanced/mainwindow.cpp:27–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25using namespace KDChart;
26
27MainWindow::MainWindow(QWidget *parent)
28 : QWidget(parent)
29{
30 setupUi(this);
31
32 auto *chartLayout = new QHBoxLayout(chartFrame);
33 m_chart = new Chart();
34 chartLayout->addWidget(m_chart);
35
36 m_model.loadFromCSV(":/data");
37
38 // Set up the diagram
39 m_bars = new BarDiagram();
40 m_bars->setModel(&m_model);
41
42 // define custom color for the borders of the bars
43 QPen pen(m_bars->pen());
44 pen.setColor(Qt::black);
45 pen.setWidth(0);
46 m_bars->setPen(pen);
47 m_chart->coordinatePlane()->replaceDiagram(m_bars);
48
49 // define custom colours for the bars
50 QList<QColor> bcolor;
51 bcolor.append(Qt::darkGreen);
52 bcolor.append(Qt::green);
53 bcolor.append(Qt::darkRed);
54 bcolor.append(Qt::red);
55 for (int row = 0; row < m_model.columnCount(); ++row) {
56 m_bars->setBrush(row, QBrush(bcolor[row]));
57 }
58
59 // Configure the plane's Background
60 BackgroundAttributes pba;
61 // pba.setBrush( QBrush(QColor(0x20,0x20,0x60)) );
62 pba.setVisible(true);
63 m_chart->coordinatePlane()->setBackgroundAttributes(pba);
64
65 m_chart->setGlobalLeadingTop(20);
66}
67
68void MainWindow::on_barTypeCB_currentIndexChanged(int index)
69{

Callers

nothing calls this directly

Calls 12

loadFromCSVMethod · 0.80
setColorMethod · 0.80
setModelMethod · 0.45
penMethod · 0.45
setPenMethod · 0.45
replaceDiagramMethod · 0.45
coordinatePlaneMethod · 0.45
columnCountMethod · 0.45
setBrushMethod · 0.45
setVisibleMethod · 0.45
setGlobalLeadingTopMethod · 0.45

Tested by

no test coverage detected