Results 1 to 9 of 9

Thread: Custom Widget Plugin Analog Clock

  1. #1
    Join Date
    Aug 2006
    Posts
    77
    Thanks
    14
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Custom Widget Plugin Analog Clock

    Hi!

    When i create a form and add custom widget example analogclock or any other custom widget on it, make a project with this form and compile it, it says:

    fatal error C1083: Cannot open include file: 'analogclock.h'

    Where is the problem?
    How can i use custom widgets in my application?
    I am using Qt 4.1.4 and VS integration 1.1.3.

    Thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Custom Widget Plugin Analog Clock

    Make sure that %QTDIR%\examples\designer\customwidgetplugin is in your includes path.

  3. #3
    Join Date
    Aug 2006
    Posts
    77
    Thanks
    14
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Custom Widget Plugin Analog Clock

    Thank you for your answer. Now it says:


    Error 1 error LNK2019: unresolved external symbol "public: __thiscall AnalogClock::AnalogClock(class QWidget *)" (??0AnalogClock@@QAE@PAVQWidget@@@Z) referenced in function "public: void __thiscall Ui_Dialog::setupUi(class QDialog *)" (?setupUi@Ui_Dialog@@QAEXPAVQDialog@@@Z) main.obj
    Error 2 fatal error LNK1120: 1 unresolved externals debug\pp.exe


    My code is:


    main.cpp
    Qt Code:
    1. #include <QApplication>
    2. #include <QDialog>
    3. #include "ui_form.h"
    4.  
    5. int main(int argc,char *argv[])
    6. {
    7. QApplication app(argc, argv);
    8. Ui::Dialog ui;
    9.  
    10. QDialog *dialog = new QDialog;
    11.  
    12. ui.setupUi(dialog);
    13. dialog->show();
    14.  
    15. return app.exec();
    16. }
    To copy to clipboard, switch view to plain text mode 
    ui_form.h
    Qt Code:
    1. #ifndef UI_FORM_H
    2. #define UI_FORM_H
    3.  
    4. #include <QtCore/QVariant>
    5. #include <QtGui/QAction>
    6. #include <QtGui/QApplication>
    7. #include <QtGui/QButtonGroup>
    8. #include <QtGui/QDialog>
    9. #include "analogclock.h"
    10.  
    11. class Ui_Dialog
    12. {
    13. public:
    14. AnalogClock *analogClock;
    15.  
    16. void setupUi(QDialog *Dialog)
    17. {
    18. Dialog->setObjectName(QString::fromUtf8("Dialog"));
    19. Dialog->resize(QSize(400, 300).expandedTo(Dialog->minimumSizeHint()));
    20. analogClock = new AnalogClock(Dialog);
    21. analogClock->setObjectName(QString::fromUtf8("analogClock"));
    22. analogClock->setGeometry(QRect(170, 140, 100, 100));
    23. retranslateUi(Dialog);
    24.  
    25. QMetaObject::connectSlotsByName(Dialog);
    26. } // setupUi
    27.  
    28. void retranslateUi(QDialog *Dialog)
    29. {
    30. Dialog->setWindowTitle(QApplication::translate("Dialog", "Dialog", 0, QApplication::UnicodeUTF8));
    31. analogClock->setToolTip(QApplication::translate("Dialog", "The current time", 0, QApplication::UnicodeUTF8));
    32. analogClock->setWhatsThis(QApplication::translate("Dialog", "The analog clock widget displays the current time.", 0, QApplication::UnicodeUTF8));
    33. Q_UNUSED(Dialog);
    34. } // retranslateUi
    35.  
    36. };
    37.  
    38. namespace Ui {
    39. class Dialog: public Ui_Dialog {};
    40. } // namespace Ui
    41.  
    42. #endif // UI_FORM_H
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Custom Widget Plugin Analog Clock

    You didn't link your program with AnalogClock's code.

  5. #5
    Join Date
    Aug 2006
    Posts
    77
    Thanks
    14
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Custom Widget Plugin Analog Clock

    Error 1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall AnalogClock::AnalogClock(class QWidget *)" (__imp_??0AnalogClock@@QAE@PAVQWidget@@@Z) referenced in function "public: void __thiscall Ui_Dialog::setupUi(class QDialog *)" (?setupUi@Ui_Dialog@@QAEXPAVQDialog@@@Z) main.obj
    Error 2 error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall AnalogClock::metaObject(void)const " (?metaObject@AnalogClock@@UBEPBUQMetaObject@@XZ) main.obj
    Error 3 error LNK2001: unresolved external symbol "public: virtual void * __thiscall AnalogClock::qt_metacast(char const *)" (?qt_metacast@AnalogClock@@UAEPAXPBD@Z) main.obj
    Error 4 error LNK2001: unresolved external symbol "public: virtual int __thiscall AnalogClock::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@AnalogClock@@UAEHW4Call@QMetaObject@ @HPAPAX@Z) main.obj
    Error 5 error LNK2001: unresolved external symbol "protected: virtual void __thiscall AnalogClock:aintEvent(class QPaintEvent *)" (?paintEvent@AnalogClock@@MAEXPAVQPaintEvent@@@Z) main.obj



    my *.pro file

    TEMPLATE = app
    TARGET +=
    DEPENDPATH += .
    INCLUDEPATH += C:\Qt\4.1.4\examples\designer\customwidgetplugin



    # Input
    FORMS += form.ui
    SOURCES += main.cpp

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Custom Widget Plugin Analog Clock

    Try:
    Qt Code:
    1. TEMPLATE = app
    2. TARGET +=
    3. DEPENDPATH += .
    4. INCLUDEPATH += C:\Qt\4.1.4\examples\designer\customwidgetplugin
    5. LIBS += -LC:\Qt\4.1.4\plugins\designer\ -lcustomwidgetplugin
    6. # Input
    7. FORMS += form.ui
    8. SOURCES += main.cpp
    To copy to clipboard, switch view to plain text mode 

  7. #7
    Join Date
    Aug 2006
    Posts
    77
    Thanks
    14
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Custom Widget Plugin Analog Clock

    Now it builds fine, but when i run the application it says:
    cannot find customwidgetplugin.dll

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Custom Widget Plugin Analog Clock

    You must copy that DLL to the same directory where your executable is.

  9. The following user says thank you to jacek for this useful post:

    kemp (11th August 2006)

  10. #9
    Join Date
    Aug 2006
    Posts
    77
    Thanks
    14
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Custom Widget Plugin Analog Clock

    Thank you very much, now it works fine.

Similar Threads

  1. Testing a custom Plugin
    By maluta in forum Qt Programming
    Replies: 5
    Last Post: 31st October 2006, 15:09
  2. Replies: 4
    Last Post: 24th March 2006, 22:50
  3. How to initialize properties to a custom plugin widget?
    By high_flyer in forum Qt Programming
    Replies: 2
    Last Post: 28th February 2006, 16:56
  4. Replies: 12
    Last Post: 15th February 2006, 10:46
  5. Managing widget plugin in Qt Designer
    By yellowmat in forum Newbie
    Replies: 8
    Last Post: 31st January 2006, 09:58

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.