
Originally Posted by
zlatko
Then post actual part of your code
The code is:
ImageZoomer.cppThis class sets the Frame wherein i would place the Canvas:
#include "imagezoomer.h"
#include <QtGui>
#include <qdir.h>
#include <QColor>
ImageZoomer::ImageZoomer(Ui::MainWindow *_mwin, Q3Canvas *pCanvas): mwin(_mwin),m_pCanvas(pCanvas)
{
frame
= new QFrame(mwin
->centralwidget
);
frame
->setGeometry
(QRect(60,
70,
591,
571));
frame
->setFrameShape
(QFrame::StyledPanel);
frame
->setFrameShadow
(QFrame::Plain);
canmouse = new CanvasMouse(m_pCanvas,frame); //Sends the canvas obj and frame obj to CanvasMouse
}
ImageZoomer::~ImageZoomer()
{
}
#include "imagezoomer.h"
#include <QtGui>
#include <qdir.h>
#include <QColor>
ImageZoomer::ImageZoomer(Ui::MainWindow *_mwin, Q3Canvas *pCanvas): mwin(_mwin),m_pCanvas(pCanvas)
{
frame = new QFrame(mwin->centralwidget);
frame->setGeometry(QRect(60, 70, 591, 571));
frame->setFrameShape(QFrame::StyledPanel);
frame->setFrameShadow(QFrame::Plain);
canmouse = new CanvasMouse(m_pCanvas,frame); //Sends the canvas obj and frame obj to CanvasMouse
}
ImageZoomer::~ImageZoomer()
{
}
To copy to clipboard, switch view to plain text mode
CanvasMouse.cpp: This class would create the canvas, set its size and set the CanvasView for it..
#include "canvasmouse.h"
CanvasMouse
::CanvasMouse(Q3Canvas
*pCanvas,
QFrame *frame
): Q3CanvasView
(frame
){
m_pCanvas = pCanvas;
Q3CanvasView::setCanvas(m_pCanvas);
m_pCanvas->setBackgroundColor(Qt::white);
m_pCanvas->resize(400, 400);
resizeContents(1000,1000);
imgdraw = new ImageDraw(m_pCanvas);
setDraw = false;
startDraw = false;
}
CanvasMouse::~CanvasMouse()
{
}
#include "canvasmouse.h"
CanvasMouse::CanvasMouse(Q3Canvas *pCanvas, QFrame *frame): Q3CanvasView(frame)
{
m_pCanvas = pCanvas;
Q3CanvasView::setCanvas(m_pCanvas);
m_pCanvas->setBackgroundColor(Qt::white);
m_pCanvas->resize(400, 400);
resizeContents(1000,1000);
imgdraw = new ImageDraw(m_pCanvas);
setDraw = false;
startDraw = false;
}
CanvasMouse::~CanvasMouse()
{
}
To copy to clipboard, switch view to plain text mode
ImageDraw.cpp: This class would actually draw the elements on the canvas and then display them... Here is the problem.. only 4 rectangles are being created as they fall out of the range of the Canvas...
#include "imagedraw.h"
#include <Q3ValueList>
ImageDraw::ImageDraw(Q3Canvas *pCanvas): m_pCanvas(pCanvas)
{
drawLine();
drawRectangle();
}
ImageDraw::~ImageDraw()
{
}
void ImageDraw::drawLine()
{
int i;
int xxPoint = 2,xyPoint = 2,yxPoint = 202,yyPoint = 2;
lineNum = 20;
m_pCanvasLine = new Q3CanvasLine*[lineNum];
for(i=0;i<lineNum;i++)
{
xyPoint = (i+1)*4;
yyPoint = xyPoint;
m_pCanvasLine[i] = new Q3CanvasLine(m_pCanvas);
m_pCanvasLine[i]->setPoints(xxPoint,xyPoint,yxPoint,yyPoint);
m_pCanvasLine[i]->show();
}
for(i=0;i<lineNum;i++)
lineList.append(m_pCanvasLine[i]);
}
void ImageDraw::drawRectangle()
{
int xPoint = 4, yPoint = 100;
int height = 50, width = 80;
int i;
recNum = 10;
m_pCanvasRectangle = new Q3CanvasRectangle*[recNum];
for(i=0;i<recNum;i++)
{
m_pCanvasRectangle[i] = new Q3CanvasRectangle(xPoint, yPoint, width, height, m_pCanvas);
m_pCanvasRectangle[i]->show();
yPoint += 75;
}
for(i=0;i<recNum;i++)
rectList.append(m_pCanvasRectangle[i]);
}
#include "imagedraw.h"
#include <Q3ValueList>
ImageDraw::ImageDraw(Q3Canvas *pCanvas): m_pCanvas(pCanvas)
{
drawLine();
drawRectangle();
}
ImageDraw::~ImageDraw()
{
}
void ImageDraw::drawLine()
{
int i;
int xxPoint = 2,xyPoint = 2,yxPoint = 202,yyPoint = 2;
lineNum = 20;
m_pCanvasLine = new Q3CanvasLine*[lineNum];
for(i=0;i<lineNum;i++)
{
xyPoint = (i+1)*4;
yyPoint = xyPoint;
m_pCanvasLine[i] = new Q3CanvasLine(m_pCanvas);
m_pCanvasLine[i]->setPoints(xxPoint,xyPoint,yxPoint,yyPoint);
m_pCanvasLine[i]->show();
}
for(i=0;i<lineNum;i++)
lineList.append(m_pCanvasLine[i]);
}
void ImageDraw::drawRectangle()
{
int xPoint = 4, yPoint = 100;
int height = 50, width = 80;
int i;
recNum = 10;
m_pCanvasRectangle = new Q3CanvasRectangle*[recNum];
for(i=0;i<recNum;i++)
{
m_pCanvasRectangle[i] = new Q3CanvasRectangle(xPoint, yPoint, width, height, m_pCanvas);
m_pCanvasRectangle[i]->show();
yPoint += 75;
}
for(i=0;i<recNum;i++)
rectList.append(m_pCanvasRectangle[i]);
}
To copy to clipboard, switch view to plain text mode
Thanks
Kapil
Bookmarks