Qt Graphical Objects & Multi-Thread
Public Member Functions | Protected Member Functions | Private Slots | Private Member Functions | Private Attributes | List of all members
UpdateWidget Class Reference

This widget draws two positions, one moved by drag and drop, the other moved by a separate thread toward the first position. More...

#include <WidgetUpdate.hpp>

Inheritance diagram for UpdateWidget:
Inheritance graph
[legend]
Collaboration diagram for UpdateWidget:
Collaboration graph
[legend]

Public Member Functions

 UpdateWidget (QWidget *parent=0)
 The widget's constructor. More...
 
 ~UpdateWidget ()
 The desctructor stops the thread. More...
 
void init ()
 Initialises both points. More...
 

Protected Member Functions

void paintEvent (QPaintEvent *event)
 Draws the position pointed by the mouse. More...
 
void mouseMoveEvent (QMouseEvent *event)
 Moves the drawn position where the mouse is, if left button is pressed. More...
 

Private Slots

void updatePosition (const int dist)
 Moves the position along a given distance toward the aimed one. More...
 

Private Member Functions

QRect region (const QPoint &pos, const bool big=false) const
 Returns the graphical region drawn around the position. More...
 
void modify (QPoint &variable, const QPoint &value)
 Memorizes a new value in a variable and redraw. More...
 

Private Attributes

QPoint position
 The position drawn in the widget. More...
 
QPoint aimed
 The aimed position, also drawn in the widget. More...
 
Updater updater
 The thread updating the position. More...
 

Detailed Description

This widget draws two positions, one moved by drag and drop, the other moved by a separate thread toward the first position.

Definition at line 106 of file WidgetUpdate.hpp.

Constructor & Destructor Documentation

UpdateWidget::UpdateWidget ( QWidget *  parent = 0)
inline

The widget's constructor.

Parameters
parentThe containing widget.

Definition at line 158 of file WidgetUpdate.hpp.

UpdateWidget::~UpdateWidget ( )
inline

The desctructor stops the thread.

Definition at line 174 of file WidgetUpdate.hpp.

Member Function Documentation

void UpdateWidget::init ( )
inline

Initialises both points.

Definition at line 177 of file WidgetUpdate.hpp.

void UpdateWidget::modify ( QPoint &  variable,
const QPoint &  value 
)
inlineprivate

Memorizes a new value in a variable and redraw.

Parameters
variableeither position or aimed,
valuethe new value for this variable.

Definition at line 125 of file WidgetUpdate.hpp.

void UpdateWidget::mouseMoveEvent ( QMouseEvent *  event)
protected

Moves the drawn position where the mouse is, if left button is pressed.

Parameters
eventThe mouse event, giving its position.

Definition at line 51 of file WidgetUpdate.cpp.

void UpdateWidget::paintEvent ( QPaintEvent *  event)
protected

Draws the position pointed by the mouse.

Parameters
eventThe drawing event, giving the region which should be redrawn.

Definition at line 34 of file WidgetUpdate.cpp.

QRect UpdateWidget::region ( const QPoint &  pos,
const bool  big = false 
) const
inlineprivate

Returns the graphical region drawn around the position.

Parameters
posThe position, a couple of integers,
bigwether the region should be increased.
Returns
The graphical region drawn around the point.

Definition at line 117 of file WidgetUpdate.hpp.

void UpdateWidget::updatePosition ( const int  dist)
inlineprivateslot

Moves the position along a given distance toward the aimed one.

Parameters
distThe distance of the motion.

Definition at line 146 of file WidgetUpdate.hpp.

Member Data Documentation

QPoint UpdateWidget::aimed
private

The aimed position, also drawn in the widget.

Definition at line 110 of file WidgetUpdate.hpp.

QPoint UpdateWidget::position
private

The position drawn in the widget.

Definition at line 109 of file WidgetUpdate.hpp.

Updater UpdateWidget::updater
private

The thread updating the position.

Definition at line 111 of file WidgetUpdate.hpp.


The documentation for this class was generated from the following files: