Skip to content

Instantly share code, notes, and snippets.

@themasch
Created March 31, 2011 16:45
Show Gist options
  • Save themasch/896739 to your computer and use it in GitHub Desktop.
Save themasch/896739 to your computer and use it in GitHub Desktop.
TextProxy *tp = new GraphicsTextProxy(blafoo);
/* edit: missed the new */
/*
* this should call GraphicsTextProxy::setText
*/
tp->setText("random");
/*
*but it calls TextProxy::setText
* WHY? And how to change it?
*/
#include "GraphicsTextProxy.h"
GraphicsTextProxy::GraphicsTextProxy(myGraphicsTextItem *item)
{
//...
}
void GraphicsTextProxy::setText(const QString &str)
{
//...
}
const QString GraphicsTextProxy::getText()
{
//...
}
#ifndef GRAPHICSTEXTPROXY_H
#define GRAPHICSTEXTPROXY_H
#include "TextProxy.h"
#include "myGraphicsTextItem.h"
class GraphicsTextProxy : public TextProxy
{
public:
GraphicsTextProxy(myGraphicsTextItem *item);
void setText(const QString &str);
const QString getText();
private:
myGraphicsTextItem *item;
};
#endif // GRAPHICSTEXTPROXY_H
#ifndef TEXTPROXY_H
#define TEXTPROXY_H
#include <QString>
class TextProxy
{
public:
virtual void setText(const QString &str) {};
virtual const QString getText() {};
};
#endif // TEXTPROXY_H
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment