Page 2 of 2 FirstFirst 12
Results 21 to 28 of 28

Thread: Custom Widget

  1. #21
    Join Date
    Feb 2010
    Posts
    30
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Custom Widget

    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

  2. #22
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,709
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Custom Widget

    now let me understand:
    when you include the above file, and do:
    Qt Code:
    1. 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:
    1. speedDialPlugin *pPlugIn = new speedDialPlugin();
    2. 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.

  3. #23
    Join Date
    Feb 2010
    Posts
    30
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Custom Widget

    Yes that is correct

  4. #24
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,709
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Custom Widget

    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.

  5. #25
    Join Date
    Feb 2010
    Posts
    30
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Custom Widget

    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

  6. #26
    Join Date
    Feb 2010
    Posts
    30
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Custom Widget

    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

  7. #27
    Join Date
    Feb 2010
    Posts
    30
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Custom 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

  8. #28
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,709
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Custom Widget

    Do I really have to add the include path for the plugin as well? What is the purpose of this plugin?
    You have to include the plugin header since you want to test the plugin it self, since it crashes.
    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.

Similar Threads

  1. Custom widget
    By zorro68 in forum Qt Programming
    Replies: 7
    Last Post: 28th January 2008, 14:06
  2. eventFilter: pop-up custom widget
    By vonCZ in forum Newbie
    Replies: 1
    Last Post: 22nd November 2007, 09:54
  3. custom plug-in widget in another custom plug-in widget.
    By MrGarbage in forum Qt Programming
    Replies: 6
    Last Post: 27th August 2007, 15:38
  4. Replies: 1
    Last Post: 5th November 2006, 23:50
  5. Replies: 9
    Last Post: 8th May 2006, 14:21

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.