Privet, sorry sorry sorry translit.
Est' problemka, mojet kto znaet reshenie :roll:
>>>>mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QtGui>
#include <QtCore>
class QLabel;
class QPaintEvent;
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow();
QApplication* q_app;
private slots:
void go();
private:
QWidget* w;
QLabel* label;
QImage image;
int temp;
protected:
void paintEvent(QPaintEvent*);
};
#endif
>>>> main.cpp
#include <QApplication>
#include "mainwindow.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
MainWindow* mw = new MainWindow;
mw->q_app = &app;
MainWindow window;
window.show();
return app.exec();
}
>>>> mainwindow.cpp
#include "mainwindow.h"
MainWindow::MainWindow()
{
w = new QWidget(this);
setCentralWidget(w);
QWidget *topFiller = new QWidget;
topFiller->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
QWidget *bottomFiller = new QWidget;
bottomFiller->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
createActions();
createMenus();
setWindowTitle(tr("Main Window"));
setMinimumSize(160, 160);
resize(480, 320);
label = new QLabel(w, 0);
label->setScaledContents(1);
QPushButton* pb = new QPushButton("&Go", this);
connect(pb, SIGNAL(triggered()), this, SLOT(go()));
temp = 1;
}
void MainWindow::go()
{
for(;;) //i have a timer here, not FOR, but it doesn't play, it to big thing to write..
{
//w->repaint();
QPaintEvent event(QRect(0, 0, roi.width, roi.height));
q_app->sendEvent(this, &event);
}
}
void MainWindow::paintEvent(QPaintEvent* event)
{
if(temp == 1)
{
printf("r\n");
label->setPixmap(QPixmap("/users/my/r.bmp"));
}
else if(temp == 2)
{
printf("s\n");
label->setPixmap(QPixmap("/users/my/s.bmp"));
temp = 0;
}
temp ++;
q_app->processEvents(QEventLoop::AllEvents);
}
T.e. kak vidno est' knopka. Pri najatii na nee doljno poluchit'sia podobie sladeshow, tol'ko is 2 partinok. Chere SENDEVENT posilaetsia event na repaint, on tyda zahodit, no pererisovki ne voznikaet. Poka ia ne cliknu drugoe okno k primeru - t.e. eshe raz ne vizovu repaintEvent! Togda da - pererisovivaet. No vedi is cikla FOR cod ZAHODIT v paintEvent - no ne pererisovivat
A tak - pererisovivaet.. V chem problema?
On english