Thank you for the answer. I applied the analog clock example to my code, but there are still
things that i don't understand.
the ratio of my drawing is correct but I don't know why my drawing is not centered properly.
I can reproduce this on an example:
#include <QLabel>
class Test_Label
: public QLabel{
Q_OBJECT
public:
protected:
};
#include <QtGui>
#include "test_label.h"
Test_Label
::Test_Label(QWidget *parent
){
}
{
int side = qMin(width(), height());
painter.translate(width() / 2, height() / 2);
painter.scale(side / 200.0, side / 200.0);
painter.drawRect(0,0,50,70);
}
#include <QLabel>
class Test_Label : public QLabel
{
Q_OBJECT
public:
Test_Label(QWidget *parent = 0);
protected:
void paintEvent(QPaintEvent *e);
};
#include <QtGui>
#include "test_label.h"
Test_Label::Test_Label(QWidget *parent)
: QLabel(parent)
{
}
void Test_Label::paintEvent(QPaintEvent *e)
{
int side = qMin(width(), height());
QPainter painter(this);
painter.translate(width() / 2, height() / 2);
painter.scale(side / 200.0, side / 200.0);
painter.drawRect(0,0,50,70);
}
To copy to clipboard, switch view to plain text mode
The rectangle is always positioned in the lower right corner. I don't understand why.
Could you please help me?
Thanks.
Bookmarks