Q_PROPERTY Problem

Alles rund um die Programmierung mit Qt
Antworten
Psychomax
Beiträge: 52
Registriert: 29. Dezember 2008 13:28

Q_PROPERTY Problem

Beitrag von Psychomax »

Hallo zusammen.

Ich wollte für meine Animation ein QGraphicsObject machen und dann setGeometry und geometry hinzuführen. Kleiner bekomme ich folgende Fehler:
moc_lockscreen.cpp:126: error: ‘geometry’ was not declared in this scope
moc_lockscreen.cpp:132: error: ‘setGeometry’ was not declared in this scope
Wäre lieb, wenn ihr mir helfen könntet.

Code: Alles auswählen

#ifndef LOCKRECTITEM_H
#define LOCKRECTITEM_H

#include <QGraphicsObject>
#include <QPainter>

class LockRectItem : public QGraphicsObject
{
Q_OBJECT
Q_PROPERTY(QRectF geometry WRITE setGeometry READ geometry)

public:
	LockRectItem(QGraphicsItem *parent = 0);
	void setGeometry(const QRectF &rect);
	QRectF geometry()const;

private:
	QRectF boundingRect() const;
	void paint(QPainter *painter,
			const QStyleOptionGraphicsItem *option,
			QWidget *widget = 0);

	int width;
	int height;
	int posX;
	int posY;

};

#endif // LOCKRECTITEM_H

#include "lockrectitem.h"

LockRectItem::LockRectItem(QGraphicsItem *parent)
	: QGraphicsObject(parent)
{
	width = 0;
	height = 0;
}

QRectF LockRectItem::boundingRect() const
{
	return QRectF(0,0,width,height);
}

void LockRectItem::paint(QPainter *painter,
		       const QStyleOptionGraphicsItem *option,
		       QWidget *widget)
{
	Q_UNUSED(option);
	Q_UNUSED(widget);

	painter->setBrush(QBrush(QColor(80,80,80)));
	painter->setPen(Qt::NoPen);
	painter->drawRect(0, 0, width, height);
}
Psychomax
Beiträge: 52
Registriert: 29. Dezember 2008 13:28

Beitrag von Psychomax »

Ok hat sich erledigt. Beim Posten vom Code ist mir aufgefallen, dass ich noch eine Klassenleiche im Code hatte! ;-) MÖP!
Antworten