Results 1 to 11 of 11

Thread: Need help making plugin

  1. #1
    Join Date
    Apr 2007
    Location
    Sunny Darwin, NT Australia
    Posts
    186
    Thanks
    29
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Need help making plugin

    I'm trying to build a plugin, but make produces an error which I don't know what to do...

    Following the directions from the book "C++ GUI Programming with Qt4"
    I have 2 parallel directories: clientNotebook which has the .ui part (compiled without errors) and clientNotebookPlugin dir.

    Problem is when I try to make the plugin, i get the following error:

    clientNotebookPlugin.cpp: In member function ‘virtual QWidget* ClientNotebookPlugin::createWidget(QWidget*)â€⠄¢:
    clientNotebookPlugin.cpp:48: error: expected type-specifier before ‘ClientNotebook’
    clientNotebookPlugin.cpp:48: error: cannot convert ‘int*’ to ‘QWidget*’ in return
    clientNotebookPlugin.cpp:48: error: expected ‘;’ before ‘ClientNotebook’
    clientNotebookPlugin.cpp:48: error: ‘ClientNotebook’ was not declared in this scope
    make: *** [clientNotebookPlugin.o] Error 1

    This is (I think is relevant) source code in the plugin directory...

    // The plugin .pro file:

    TEMPLATE = lib
    CONFIG += designer plugin release

    HEADERS += ../clientNotebook/clientNotebook.h\
    clientNotebookPlugin.h
    SOURCES += ../clientNotebook/clientNotebook.cpp\
    clientNotebookPlugin.cpp

    DESTDIR = /usr/local/Qt4.3/plugins/designer
    // eof

    // The plugin cpp file:

    #include <QtPlugin>

    #include "./clientNotebookPlugin.h"

    ClientNotebookPlugin::ClientNotebookPlugin(QObject *parent)
    : QObject (parent)
    {
    }

    .... name() includeFile() group() etc...

    // This is the problem function...

    QWidget *ClientNotebookPlugin::createWidget(QWidget *parent)
    {
    return new ClientNotebook(parent);
    }

    Q_EXPORT_PLUGIN2(clientNotebookPlugin, ClientNotebookPlugin)

    // eof

    // plugin.h file:
    #ifndef CLIENTNOTEBOOKPLUGIN_H
    #define CLIENTNOTEBOOKPLUGIN_H

    #include <QDesignerCustomWidgetInterface>


    class ClientNotebookPlugin : public QObject, public QDesignerCustomWidgetInterface
    {
    Q_OBJECT
    Q_INTERFACES(QDesignerCustomWidgetInterface)

    public:
    ClientNotebookPlugin(QObject *parent = 0);
    QString name() const;
    QString includeFile() const;
    QString group() const;
    QIcon icon() const;
    QString toolTip() const;
    QString whatsThis() const;
    bool isContainer() const;
    QWidget *createWidget(QWidget *parent);
    };

    #endif

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Need help making plugin

    Try including "clientNotebook.h" in clientNotebookPlugin.cpp.
    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    vieraci (22nd September 2007)

  4. #3
    Join Date
    Apr 2007
    Location
    Sunny Darwin, NT Australia
    Posts
    186
    Thanks
    29
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Need help making plugin

    Now that I've inserted the plugin into a form, it doesn't compile:

    In file included from mainmenu.h:19,
    from main.cpp:16:
    ui_mainmenu.h:36:34: error: clientNotebookPlugin.h: No such file or directory
    In file included from mainmenu.h:20,
    from main.cpp:16:
    clientNotebookPlugin/clientNotebookPlugin.h:4:42: error: QDesignerCustomWidgetInterface: No such file or directory

    Why is ui_mainmenu.h not resolving ?
    Doesn't Qt look in the plugin dir for it ?
    Do I need to set something in .pro file ?

  5. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Need help making plugin

    Quote Originally Posted by vieraci View Post
    ui_mainmenu.h:36:34: error: clientNotebookPlugin.h: No such file or directory
    Does ClientNotebookPlugin::includeFile() return "clientNotebookPlugin.h"? If so, make it return "clientNotebook.h" (or whatever is the correct file name).

    clientNotebookPlugin/clientNotebookPlugin.h:4:42: error: QDesignerCustomWidgetInterface: No such file or directory
    Try adding "CONFIG += designer" to the .pro file (and re-generating the vs project).
    J-P Nurmi

  6. #5
    Join Date
    Apr 2007
    Location
    Sunny Darwin, NT Australia
    Posts
    186
    Thanks
    29
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Need help making plugin

    Quote Originally Posted by jpn View Post
    Does ClientNotebookPlugin::includeFile() return "clientNotebookPlugin.h"? If so, make it return "clientNotebook.h" (or whatever is the correct file name).
    YES ! ok, fixed, rebuilt plugin, cleaned project, rebuilt...but now:

    In file included from mainmenu.h:19,
    from main.cpp:8:
    ui_mainmenu.h:36:28: error: clientNotebook.h: No such file or directory

    Quote Originally Posted by jpn View Post
    Try adding "CONFIG += designer" to the .pro file (and re-generating the vs project).
    No difference.

  7. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Need help making plugin

    The plugin is just for using clientNotebook in designer. You still need to include clientNotebook to you project.
    J-P Nurmi

  8. #7
    Join Date
    Apr 2007
    Location
    Sunny Darwin, NT Australia
    Posts
    186
    Thanks
    29
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Unhappy Re: Need help making plugin

    Thanks again, that should have been obvious to me.
    Now I'm receiving yet ANOTHER undefined reference...

    mainmenu.o: In function `Ui_MainMenu::setupUi(QMainWindow*)':
    mainmenu.cpp.text._ZN11Ui_MainMenu7setupUiEP11QMainWindow[Ui_MainMenu::setupUi(QMainWindow*)]+0x2094): undefined reference to `ClientNotebook::ClientNotebook(QWidget*)'
    mainmenu.cpp.text._ZN11Ui_MainMenu7setupUiEP11QMainWindow[Ui_MainMenu::setupUi(QMainWindow*)]+0x296d): undefined reference to `ClientNotebook::ClientNotebook(QWidget*)'
    collect2: ld returned 1 exit status

    Sorry, I've spent hours over this but I can't work out why. I wish I had more knowledge :-(

    I tried placing the cpp and .o files in the same directory but it didn''t help.

  9. #8
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Need help making plugin

    Did you add clientNotebook.h and clientNotebook.cpp to the application's .pro file?
    J-P Nurmi

  10. #9
    Join Date
    Apr 2007
    Location
    Sunny Darwin, NT Australia
    Posts
    186
    Thanks
    29
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Need help making plugin

    ok, added them, new error message:

    clientNotebook.o: In function `ClientNotebook::ClientNotebook(QWidget*)':
    clientNotebook.cpp.text+0x31): undefined reference to `vtable for ClientNotebook'
    clientNotebook.cpp.text+0x38): undefined reference to `vtable for ClientNotebook'
    clientNotebook.o: In function `ClientNotebook::ClientNotebook(QWidget*)':
    clientNotebook.cpp.text+0xb1): undefined reference to `vtable for ClientNotebook'
    clientNotebook.cpp.text+0xb8): undefined reference to `vtable for ClientNotebook'

    Am using 2
    clientNotebook widgets in mainMenu, hence error message twice.

  11. #10
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Need help making plugin

    Did you remember to re-run qmake or did you just add the file through an IDE or so?
    J-P Nurmi

  12. The following user says thank you to jpn for this useful post:

    vieraci (24th September 2007)

  13. #11
    Join Date
    Apr 2007
    Location
    Sunny Darwin, NT Australia
    Posts
    186
    Thanks
    29
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Need help making plugin

    That was it !!
    I mistakenly put the header file listed in SOURCES instead of HEADERS...

    SOURCES = main.cpp \
    mainmenu.cpp \
    clientNotebook/clientNotebook.cpp \
    clientNotebook/clientNotebook.h

    Thank you very much. :-)

Similar Threads

  1. QPluginLoader not recognizing a plugin
    By KShots in forum Qt Programming
    Replies: 3
    Last Post: 29th June 2007, 14:13
  2. plugin loading problem
    By naresh in forum Qt Programming
    Replies: 6
    Last Post: 9th June 2007, 19:05
  3. Qt Designer plugin on windows
    By big4mil in forum Newbie
    Replies: 4
    Last Post: 30th May 2007, 17:33
  4. Qt4 win opensource + mysql plugin
    By vr in forum Installation and Deployment
    Replies: 3
    Last Post: 25th May 2007, 09:01
  5. Replies: 13
    Last Post: 15th December 2006, 11:52

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.