Results 1 to 13 of 13

Thread: Installing plugins

  1. #1
    Join Date
    Jan 2008
    Posts
    11
    Qt products
    Qt4
    Platforms
    Windows

    Default Installing plugins

    I'm new with Qt, and I'm trying to make a plugin for the designer. It doesnt seem like it should be that difficult, and I've followed the assistant and examples to create the two necessary classes. The assistant is detailed, but painfully ignorant of how to actually install the plugin.

    Since I'm working with Visual Studio, until now my qmake commands have been "qmake -project" and "qmake -tp vc," and a .dsp file would be created that holds the necessary files.

    What do I need to do to get the plugin installed to use in the Designer? I made the project files as described in the assistant, but my arsenal of qmake commands is not getting the job done. Suggestions?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Installing plugins

    Copy the resulting library into plugins/designer subdirectory of your Qt installation or MSVC integration directory.

  3. #3
    Join Date
    Jan 2008
    Posts
    11
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Installing plugins

    hmm... I have not gotten to the point where it creates a library, either .dll or .lib. I think I'm still missing a step.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Installing plugins

    "nmake" in the console or "Build" in the IDE? BTW. Before you run qmake -tp vc, you need to alter the .pro file to tell it to actually build the plugin and not an application. It's all mentioned in the docs.

  5. #5
    Join Date
    Jan 2008
    Posts
    11
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Installing plugins

    I found the library files in the release folder. It's all good. Thanks for your help

  6. #6
    Join Date
    Jan 2008
    Posts
    11
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Installing plugins

    New problem... I'm trying to make another plugin. This plugin, ClickArea, will just be a widget that has nothing on it, but can be clicked. One of the new properties will be an int Index, so that when clicked it will send its index value to a different widget or to a different function.
    I made the class public of QAbstractButton and made an empty paint function. I put together the plugin based off the one I made earlier (which works), but this time I get an error in the moc code that says "definition of dll static import data member not allowed." There are also warnings in the moc that say "inconsistent dll linkage."

    Any idea about what I'm doing wrong to cause these errors? I'm at a loss about what to do, since I cannot change the moc code directly.
    If you need me to post any of the classes, I can certainly do so.

    Thanks

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Installing plugins

    Hard to say without seeing the code. You surely lack the dllexport/dllimport declaration.

  8. #8
    Join Date
    Jan 2008
    Posts
    11
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Installing plugins

    Sorry it took so long to reply. I'm not sure what you mean about dllexport and dllimport (I found that they are macros, but beyond that I dont know what they do).

    Here's the code. There is a "clickarea" header and cpp file, and a "clickareaplugin" header and cpp file.

    Qt Code:
    1. //ClickArea.h
    2. #ifndef CLICKAREA_H
    3. #define CLICKAREA_H
    4. #include <QtGui/QAbstractButton>
    5. #include <QtDesigner/QDesignerExportWidget>
    6. QT_BEGIN_HEADER
    7. QT_MODULE(Gui)
    8.  
    9. class QDESIGNER_WIDGET_EXPORT ClickArea : public QAbstractButton
    10. {
    11. Q_OBJECT
    12. Q_PROPERTY(int Index READ getIndex WRITE setIndex)
    13.  
    14. public:
    15. ClickArea(QWidget *parent = 0);
    16. int getIndex() const;
    17.  
    18. protected:
    19. void paintEvent(QPaintEvent *e);
    20. void mousePressEvent(QMouseEvent *event);
    21. void mouseReleaseEvent(QMouseEvent *event);
    22.  
    23. public Q_SLOTS:
    24. void setIndex(const int);
    25.  
    26. signals:
    27. void pressed();
    28. void released();
    29. void clicked(int);
    30.  
    31. private:
    32. int Index;
    33.  
    34. };
    35.  
    36. QT_END_HEADER
    37. #endif
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. //ClickArea.cpp
    2. #include "clickarea.h"
    3. #include <QtGui/QtGui.h>
    4.  
    5. ClickArea::ClickArea(QWidget *parent): QAbstractButton(parent)
    6. {
    7.  
    8. }
    9. void ClickArea::mousePressEvent(QMouseEvent *event)
    10. {
    11. emit pressed();
    12. }
    13. void ClickArea::mouseReleaseEvent(QMouseEvent *event)
    14. {
    15. emit released();
    16. emit clicked(Index);
    17. }
    18. void ClickArea::paintEvent(QPaintEvent *e)
    19. {
    20.  
    21. }
    22. void ClickArea::setIndex(const int value)
    23. {
    24. Index = value;
    25. }
    26. int ClickArea::getIndex() const
    27. {
    28. return Index;
    29. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. //ClickAreaPlugin.h
    2.  
    3. #ifndef CLICKAREAPLUGIN_H
    4. #define CLICKAREAPLUGIN_H
    5. #include <QtDesigner/QDesignerCustomWidgetInterface>
    6.  
    7. class ClickAreaPlugin: public QObject, public QDesignerCustomWidgetInterface
    8. {
    9. Q_OBJECT
    10.  
    11. public:
    12. ClickAreaPlugin(QObject *parent = 0);
    13.  
    14. bool isContainer() const;
    15. bool isInitialized() const;
    16. QIcon icon() const;
    17. QString domXml() const;
    18. QString group() const;
    19. QString includeFile() const;
    20. QString name() const;
    21. QString toolTip() const;
    22. QString whatsThis() const;
    23. QWidget *createWidget(QWidget *parent);
    24. void initialize(QDesignerFormEditorInterface *core);
    25.  
    26. private:
    27. bool initialized;
    28. };
    29.  
    30. #endif
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. //ClickAreaPlugin.cpp
    2. #include "clickareaplugin.h"
    3. #include "clickarea.h"
    4. #include <QtPlugin>
    5.  
    6. ClickAreaPlugin::ClickAreaPlugin(QObject *parent)
    7. : QObject(parent)
    8. {
    9. initialized = false;
    10. }
    11. void ClickAreaPlugin::initialize(QDesignerFormEditorInterface *)
    12. {
    13. if (initialized)
    14. return;
    15. initialized = true;
    16. }
    17.  
    18. bool ClickAreaPlugin::isInitialized() const
    19. {
    20. return initialized;
    21. }
    22. QWidget *ClickAreaPlugin::createWidget(QWidget *parent)
    23. {
    24. return new ClickArea(parent);
    25. }
    26. QString ClickAreaPlugin::name() const
    27. {
    28. return "ClickArea";
    29. }
    30. QString ClickAreaPlugin::group() const
    31. {
    32. return "Buttons";
    33. }
    34. QIcon ClickAreaPlugin::icon() const
    35. {
    36. return QIcon();
    37. }
    38. QString ClickAreaPlugin::toolTip() const
    39. {
    40. return "";
    41. }
    42. QString ClickAreaPlugin::whatsThis() const
    43. {
    44. return "";
    45. }
    46. bool ClickAreaPlugin::isContainer() const
    47. {
    48. return false;
    49. }
    50. QString ClickAreaPlugin::domXml() const
    51. {
    52. return "<widget class=\"Click Area\" name=\"ClickArea\">\n"
    53. " <property name=\"geometry\">\n"
    54. " <rect>\n"
    55. " <x>0</x>\n"
    56. " <y>0</y>\n"
    57. " <width>100</width>\n"
    58. " <height>100</height>\n"
    59. " </rect>\n"
    60. " </property>\n"
    61. "</widget>\n";
    62. }
    63. QString ClickAreaPlugin::includeFile() const
    64. {
    65. return "clickarea.h";
    66. }
    67. Q_EXPORT_PLUGIN2(clickareaplugin, ClickAreaPlugin)
    To copy to clipboard, switch view to plain text mode 

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Installing plugins

    I think the plugin class needs an export declaration as well.

  10. #10
    Join Date
    Jan 2008
    Posts
    11
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Installing plugins

    I'll try it. Are you talking about the QDESIGNER_WIDGET_EXPORT in the first class?

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Installing plugins

    Yes. That the dllimport/dllexport I was referring to. Look what this macro you cited expands to.

  12. #12
    Join Date
    Sep 2006
    Posts
    20
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Installing plugins

    Perhaps you can remove the Q_PROPERTY macro from ClickArea.h.
    My similar designer plugin lives without this declaration.

  13. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Installing plugins

    Q_PROPERTY statement is perfectly valid there.

Similar Threads

  1. Qt Plugins Error
    By nathanpackard in forum Qt Programming
    Replies: 1
    Last Post: 18th August 2007, 00:19
  2. Nightmares with plugins
    By KShots in forum Qt Programming
    Replies: 6
    Last Post: 8th February 2007, 17:46
  3. Qt plugins - how to do a libtool-style autoload
    By KShots in forum Qt Programming
    Replies: 2
    Last Post: 7th February 2007, 13:40
  4. Arthur Plugins demos and designer
    By antonio.r.tome in forum Installation and Deployment
    Replies: 4
    Last Post: 21st March 2006, 15:01
  5. Plugins as small application
    By blackliteon in forum Qt Programming
    Replies: 4
    Last Post: 12th January 2006, 10:39

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.