But i cant create an instance of my custom widget since the compiler doesn´t recognize the type when I try to include speedDial.h
But i cant create an instance of my custom widget since the compiler doesn´t recognize the type when I try to include speedDial.h
post your speedDial.h (please, not in as a link!)
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
My custom widget is actually just the svgDialgauge wich is just included in my speedDialPlugin project as a .pri. So my speedDial.h would be qtSvgDialGauge.h I have ofcourse tried including qtsvgdialgauge.h and speedDialPlugin.h but the compiler doesnt recohnize these as well even when im linking to the lib file as we talked about earlier. The qtsvgdialgauge.h is located in a sub folder of my pluginprojectfolder.
So my plugin project consists of
speedDialPlugin.h
speedDialPlugin.cpp
(Included by .pri files)
qtSvgDialGauge.h
qtSvgDialGauge.cpp
qtSvgPixMapCache.h
qtSvgPixMapCache.cpp
qtSvgPixMapCache is used by svgDialGauge. And svgDialGauge is the widget created in the createWidget() function in speedDialPlugin.cpp
/*
Embedded Widgets Demo
Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).*
Contact: Qt Software Information (qt-info@nokia.com)**
This file may be used under the terms of the Embedded Widgets Demo License
Agreement.
*/
#ifndef QT_SVG_DIAL_GAUGE
#define QT_SVG_DIAL_GAUGE
#include <QtGui/QWidget>
#include <QtCore/QPair>
#include <QtDesigner/QDesignerExportWidget>
class QSvgRenderer;
class QtSvgPixmapCache;
class QDESIGNER_WIDGET_EXPORT QtSvgDialGauge : public QWidget
{
Q_OBJECT
Q_PROPERTY(QString skin READ skin WRITE setSkin)
Q_PROPERTY(int minimum READ minimum WRITE setMinimum)
Q_PROPERTY(int maximum READ maximum WRITE setMaximum)
Q_PROPERTY(qreal startAngle READ startAngle WRITE setStartAngle)
Q_PROPERTY(qreal endAngle READ endAngle WRITE setEndAngle)
public:
explicit QtSvgDialGauge(QWidget * parent = 0);
~QtSvgDialGauge();
void setSkin(const QString& skin);
QString skin() const;
void setMinimum(int minimum);
void setMaximum(int maximum);
void setNeedleOrigin(qreal x, qreal y);
void setStartAngle(qreal angle);
void setEndAngle(qreal angle);
int value() const;
int minimum() const;
int maximum() const;
qreal needleOriginX() const;
qreal needleOriginY() const;
qreal startAngle() const;
qreal endAngle() const;
virtual QSize minimumSizeHint() const;
virtual QSize sizeHint() const;
void setShowOverlay(bool);
public slots:
void setValue(int value);
private:
void init();
QRectF availableRect(QtSvgPixmapCache * renderObject) const;
QtSvgPixmapCache* m_backgroundRenderer;
QtSvgPixmapCache* m_needleShadowRenderer;
QSvgRenderer* m_needleRenderer;
QRectF availableRect(QSvgRenderer * renderObject) const;
QtSvgPixmapCache* m_overlayRenderer;
/** minimum possible value **/
int m_minimum;
/** maximum possible value **/
int m_maximum;
/** actual value **/
int m_value;
/** smallest start angle **/
qreal m_startAngle;
/** highest end angle **/
qreal m_endAngle;
/** position x of needle **/
qreal m_originX;
/** position y of needle **/
qreal m_originY;
bool m_showOverlay;
/** name of actual skin **/
QString m_skin;
protected:
void paintEvent(QPaintEvent * event);
};
#endif // QT_SVG_DIAL_GAUGE
now let me understand:
when you include the above file, and do:
Qt Code:
QtSvgDialGauge *pDialGauge = new QtSvgDialGauge(this);To copy to clipboard, switch view to plain text mode
you get an undefined type?
Where as, this is also not exactly what I meant.
You should include your plugin header, and link directly to your plugin, in order to test it.
So in your case it will be something like:
Qt Code:
speedDialPlugin *pPlugIn = new speedDialPlugin(); QtSvgDialGauge *pDialGauge = pPlugIn->createWidget();To copy to clipboard, switch view to plain text mode
Your project needs to know the include paths to all the classes that you will be using.
Last edited by high_flyer; 12th February 2010 at 15:38.
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
Yes that is correct
can you post the compiler output when you build?
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
So I added include paths and now I Get the following error
ld: library not found for -libspeeddialplugin.dylib
Even though the file is there and my .pro file has the line:
LIBS += -L/Developer/Applications/Qt/plugins/designer -libspeeddialplugin.dylib
or
LIBS += -L/Developer/Applications/Qt/plugins/designer -libspeeddialplugin
or
LIBS += Developer/Applications/Qt/plugins/designer/libspeeddialplugin
Ok so I managed to get passed that problem and know the plugin lib should be loaded and I have added all include paths. It still cannot use speedDialPlugin.h or create an instance of this class. Do I really have to add the include path for the plugin as well? What is the purpose of this plugin? I thought it would work just to include the lib file and then I could start playing around with my widget
Im having my monolog here
Now I have included the path to the plugin as well and can start using the speeddialplugin.h fiiles but now the compiler complines about the plugin files which previously compiled nice when I generated the .lib file.
Errors:
/speeddialplugin.h:4: error: QDesignerCustomWidgetInterface: No such file or directory
/speeddialplugin.h:7: error: expected class-name before '{' token
/speeddialplugin.h:24: error: 'QDesignerFormEditorInterface' has not been declared
Strange since it compiled nicely when I created the lib file
You have to include the plugin header since you want to test the plugin it self, since it crashes.Do I really have to add the include path for the plugin as well? What is the purpose of this plugin?
In previous posts you said you tried your custom widget directly and that it worked.
So now you need to see what the problem is with the plugin, which means you have to link to the plugin class to see where the problem occurs.
Your problem is that you don't know your work environment tools/IDE, and how to configure it.
Its hard to help you with that, unless you post specific questions on settings issues.
In general, when you link against a lib, you need to specify the path to that lib, and all the headers you will be using.
If the compile complains it can't find files, it means your project settings are not correct.
I am sure speeddialplugin.h is not in the root of your file system, which is where the compiler is looking for them. -> /speeddialplugin.h.
You have to specify the path to your headers - make sure your syntax is correct (in a *.pro file, or what ever method you use to specify project settings)
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
Bookmarks