1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#ifndef __GRAPHICWIN_H
#define __GRAPHICWIN_H
#include <qscrollview.h>
#include <qpixmap.h>
#include <qpushbutton.h>
#include <qlayout.h>
class GraphicScroll : public QScrollView
{
Q_OBJECT
QWidget* m_picture;
protected:
void hideEvent( QHideEvent * p)
{
m_picture->setFixedSize(1,1);
}
public:
GraphicScroll( QWidget *parent=0, const char *name=0, WFlags f = 0)
: QScrollView(parent, name, f)
{
m_picture = new QWidget(viewport());
addChild(m_picture);
}
void setPixmap(QPixmap& pm)
{
m_picture->setFixedSize(pm.size());
m_picture->setBackgroundPixmap(pm);
}
/*
private slots:
void graphicClose() { emit Close(); }
signals:
void Close();
*/
};
class GraphicWin : public QWidget
{
Q_OBJECT
GraphicScroll* m_scroll;
signals:
void Closed();
private slots:
void slotClosed() { emit Closed(); }
public:
void setPixmap(QPixmap& pm) { m_scroll->setPixmap(pm); }
GraphicWin( QWidget *parent=0, const char *name=0, WFlags f = 0)
: QWidget(parent, name, f)
{
QVBoxLayout* grid = new QVBoxLayout(this);
m_scroll = new GraphicScroll(this);
QPushButton* exitButton = new QPushButton("Close", this);
connect(exitButton, SIGNAL( released() ), this, SLOT( slotClosed() ) );
grid->addWidget(m_scroll,1);
grid->addWidget(exitButton);
}
};
#endif
|