qt


Using QCustomPlot trying to create animation like effect


i am trying to create a bar graph whose bars value increases overtime until max value is reached so that animation like effect is displayed but the plotting of graph is done only at the last data is set
void Analysis::drawGraph()
{
ui->customPlot->clearPlottables();
QBrush gray(Qt::gray);
qDebug()<<month[0]<<month[1]<<month[2]<<month[3]<<month[4]<<month[5]<<month[6]<<month[7]<<month[8]<<month[9]<<month[10]<<month[11];
ui->customPlot->setBackground(gray);
// create empty bar chart objects:
QCPBars *bar = new QCPBars(ui->customPlot->xAxis, ui->customPlot->yAxis);
bar->setName("barerative");
bar->setPen(QPen(QColor(0, 168, 140).lighter(130)));
bar->setBrush(QColor(0, 168, 140));
// prepare x axis with country labels:
QVector<double> ticks;
QVector<QString> labels;
ticks << 1 << 2 << 3 << 4 << 5 << 6 << 7<<8<<9<<10<<11<<12;
labels << "January" << "February" << "March" << "April" << "May" << "June" << "July"<<"August"<<"September"<<"October"<<"November"<<"December";
QSharedPointer<QCPAxisTickerText> textTicker(new QCPAxisTickerText);
textTicker->addTicks(ticks, labels);
ui->customPlot->xAxis->setTicker(textTicker);
ui->customPlot->xAxis->setRange(0, 13);
ui->customPlot->xAxis->grid()->setVisible(true);
ui->customPlot->xAxis->setTickLabelColor(Qt::black);
ui->customPlot->xAxis->setTickLabelFont(QFont("Times",14,2));
int maxSaleMonthValue=0;
for (int i=0; i<12; i++)
{
if (month[i] > maxSaleMonthValue)
maxSaleMonthValue = month[i];
}
qDebug()<<maxSaleMonthValue;
// prepare y axis:
ui->customPlot->yAxis->setRange(0, maxSaleMonthValue+2);
ui->customPlot->yAxis->setLabel("Total Sale");
ui->customPlot->yAxis->setBasePen(QPen(Qt::white));
ui->customPlot->yAxis->setTickPen(QPen(Qt::white));
ui->customPlot->yAxis->setSubTickPen(QPen(Qt::white));
ui->customPlot->yAxis->grid()->setSubGridVisible(false);
ui->customPlot->yAxis->setTickLabelColor(Qt::white);
ui->customPlot->yAxis->setLabelColor(Qt::white);
ui->customPlot->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::SolidLine));
ui->customPlot->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine));
// Add data:
QVector<double> Data;
float move=0;
while(move<1)
{
move=move+0.1;
Data.clear();
Data<<move*month[0]<<move*month[1]<<move*month[2]<<move*month[3]<<move*month[4]<<move*month[5]<<move*month[6]<<move*month[7]<<move*month[8]<<move*month[9]<<move*month[10]<<move*month[11];
this->thread()->msleep(500);
bar->setData(ticks, Data);
qDebug()<<Data;
this->resize(this->width()-1,this->height()-1);//plotting is only done while resizing the window
this->resize(this->width()+1,this->height()+1);
}
}

Related Links

Qt4 starting and stopping (pausing)
Can I draw Qt objects directly to Win32 DC (Device Context)?
Is there a poster for Qt documentation?
get several values from the user in QT
How to execute program which have created Qt on windows?
Lock error while running program in Qt/C++
Where is qembed tool in QT4.5?
QDir and QDirIterator ignore files with non-ASCII filenames
Is there a way to package a dynamic library in the application binary?
Can I decide where a Qaction is added to a Qmenubar
Modifying Qt core components/widgets, best practices? [closed]
How to connect menu click with action in Qt Creator?
How to set output path in a Qt project
How about using SVG(Scalable Vector Graphics) on desktop applications?
Using gSoap in Qt/Windows
Problems with QDialog in Qt

Categories

HOME
amazon-web-services
office365
seedstack
bokeh
haproxy
android-emulator
tcp
elisp
apache-kafka-connect
cdi
scrape
alljoyn
feature-extraction
jpa-2.0
xbox360
maven-plugin
el
fido-u2f
substring
firemonkey-style
jpa-2.1
managed-c++
tracing
php-5.3
django-import-export
boolean-logic
android-collapsingtoolbar
custom-keyboard
jade4j
tidal-scheduler
assemblies
flowchart
julius-speech
type-inference
sony-future-lab-n
password-hash
lightning-workbench
redisson
simple-schema
freshdesk
nrf51
xcode6.4
jsonix
jpda
system.web.optimization
openseadragon
flask-security
phpquery
miniconda
linuxbrew
chicagoboss
android-studio-import
gitlab-omnibus
hmisc
supersocket.net
com0com
whitespace-language
prism-4
debug-symbols
aho-corasick
maven-central
roxy-fileman
spring-security-acl
application-blocks
compiler-flags
visual-c++-2005
ldif
pacman
sunstudio
notin
lynx
coordinate
microblogging
haiku
play2-mini
firefly-mv
office-automation
grails-validation
raw-data
.net-services
getimagesize
spring-modules
source-code-protection
subtext
ning
word-automation

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App