23 srp 2015, 06:44
28 srp 2015, 08:56
24 kol 2015, 13:52
void MainWindow::paintEvent(QPaintEvent *e)
{
QPainter painter(this);
painter.drawLine(10,10,1000,800);
}
void MainWindow::on_pushButton_3_clicked()
{
QPainter painter(this);
painter.drawLine(10,10,1000,800);
}
24 kol 2015, 15:39
[izvor]The common use of QPainter is inside a widget's paint event: Construct and customize (e.g. set the pen or the brush) the painter. Then draw. Remember to destroy the QPainter object after drawing.
24 kol 2015, 16:26
24 kol 2015, 18:39
maliodpalube je napisao/la:S this.update nestanu mi stari krugovi i pojavi se novi.
26 kol 2015, 14:11
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QTime>
int crtaj;
void cekaj(int);
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
crtaj=0;//flag da se ne crta kod pokretanja programa
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::paintEvent(QPaintEvent *e)
{
if(crtaj==1)
{
QPainter painter(this);
painter.setPen(Qt::red);
painter.setBrush(Qt::red);
painter.drawEllipse(QPoint(100,100),10,10);
//cekaj(3000);
painter.drawEllipse(QPoint(130,130),10,10);
}
}
void MainWindow::on_pushButton_clicked()
{
if(crtaj==0)
crtaj=1;
else
crtaj=0;
this->update();
}
void cekaj( int milisekunde )
{
QTime dieTime = QTime::currentTime().addMSecs( milisekunde );
while( QTime::currentTime() < dieTime )
{
QCoreApplication::processEvents( QEventLoop::AllEvents, 100 );
}
}
31 kol 2015, 17:09
stefan je napisao/la:Onda u paintEvent-u crtaj sve krugove koje je potrebno vidjeti u tom trenutku, a ne samo "nadodati" nove.
01 ruj 2015, 10:28