Results 1 to 14 of 14

Thread: Can't create my custom QGraphicsView for QDesigner

  1. #1
    Join Date
    Apr 2007
    Posts
    117
    Thanks
    84
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Can't create my custom QGraphicsView for QDesigner

    Hello I am trying to create my own custom QGraphicsView to be used by QtDesigner. This is my code and I based it on customclockwidget that I read in QtAssistant
    Qt Code:
    1. #ifndef CUSTOMGVPLUGIN_H
    2. #define CUSTOMGVPLUGIN_H
    3. #include <QDesignerCustomWidgetInterface>
    4. class customgvPlugin : public QObject, public QDesignerCustomWidgetInterface {
    5. Q_OBJECT
    6.  
    7. public:
    8. customgvPlugin(QObject *parent = 0);
    9.  
    10. bool isContainer() const;
    11. bool isInitialized() const;
    12. QIcon icon() const;
    13. QString domXml() const;
    14. QString group() const;
    15. QString includeFile() const;
    16. QString name() const;
    17. QString toolTip() const;
    18. QString whatsThis() const;
    19. QGraphicsView *createWidget(QGraphicsScene *scene, QWidget *parent);
    20. void initialize(QDesignerFormEditorInterface *core);
    21.  
    22. private:
    23. bool initialized;
    24. };
    25. #endif
    To copy to clipboard, switch view to plain text mode 

    This is the error
    customgvplugin.h:3:43: error: QDesignerCustomWidgetInterface: No such file or directory
    What could be the cause of this? I'm running qt in Ubuntu Feisty Fawn. my make install for Qt-4.3.1 had no errors at all
    Last edited by sincnarf; 12th October 2007 at 02:29. Reason: fixed code
    Image Analysis Development Framework Using Qt (IADFUQ)

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Can't create my custom QGraphicsView for QDesigner

    Does your pro file contains
    CONFIG += designer plugin
    ?

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

    sincnarf (12th October 2007)

  4. #3
    Join Date
    Apr 2007
    Posts
    117
    Thanks
    84
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Can't create my custom QGraphicsView for QDesigner

    Quote Originally Posted by marcel View Post
    Does your pro file contains ?
    Thanks for that. Now it has the error
    customgvplugin.cpp: In function ‘QObject* qt_plugin_instance()’:
    customgvplugin.cpp:73: error: cannot allocate an object of abstract type ‘customgvPlugin’
    customgvplugin.h:4: note: because the following virtual functions are pure within ‘customgvPlugin’:
    /usr/local/Trolltech/Qt-4.3.1/include/QtDesigner/customwidget.h:66: note: virtual QWidget* QDesignerCustomWidgetInterface::createWidget(QWidg et*)
    make[1]: *** [release/customgvplugin.o] Error 1
    make[1]: Leaving directory `/root/workspace/IADFUQ/PLUGINS/customgvplugin'
    make: *** [release] Error 2
    this is on last line
    Qt Code:
    1. Q_EXPORT_PLUGIN2(customgvplugin, customgvPlugin)
    To copy to clipboard, switch view to plain text mode 

    here' the full code of the plugin
    Qt Code:
    1. #include "customgv.h"
    2. #include "customgvplugin.h"
    3.  
    4. #include <QtPlugin>
    5.  
    6. customgvPlugin::customgvPlugin(QObject *parent):QObject(parent) {
    7. initialized = false;
    8. }
    9.  
    10. void customgvPlugin::initialize(QDesignerFormEditorInterface *) {
    11. if (initialized)
    12. return;
    13.  
    14. initialized = true;
    15. }
    16.  
    17. bool customgvPlugin::isInitialized() const {
    18. return initialized;
    19. }
    20.  
    21. QGraphicsView *customgvPlugin::createWidget(QGraphicsScene *scene, QWidget *parent)
    22. {
    23. return new customgv(scene, parent);
    24. }
    25.  
    26. QString customgvPlugin::name() const {
    27. return "IADFUQGraphicsView";
    28. }
    29.  
    30. QString customgvPlugin::group() const {
    31. return "Display Widgets [Examples]";
    32. }
    33.  
    34. QIcon customgvPlugin::icon() const {
    35. return QIcon();
    36. }
    37.  
    38. QString customgvPlugin::toolTip() const {
    39. return "";
    40. }
    41.  
    42. QString customgvPlugin::whatsThis() const {
    43. return "";
    44. }
    45.  
    46. bool customgvPlugin::isContainer() const {
    47. return false;
    48. }
    49.  
    50. QString customgvPlugin::domXml() const {
    51. return "<widget class=\"customgv\" name=\"customgv\">\n"
    52. " <property name=\"geometry\">\n"
    53. " <rect>\n"
    54. " <x>0</x>\n"
    55. " <y>0</y>\n"
    56. " <width>100</width>\n"
    57. " <height>100</height>\n"
    58. " </rect>\n"
    59. " </property>\n"
    60. " <property name=\"toolTip\" >\n"
    61. " <string>IADFUQ GRAPHICS VIEW</string>\n"
    62. " </property>\n"
    63. " <property name=\"whatsThis\" >\n"
    64. " <string>IADFUQ GRAPHICS VIEW</string>\n"
    65. " </property>\n"
    66. "</widget>\n";
    67. }
    68.  
    69. QString customgvPlugin::includeFile() const {
    70. return "customgv.h";
    71. }
    72.  
    73. Q_EXPORT_PLUGIN2(customgvplugin, customgvPlugin)
    To copy to clipboard, switch view to plain text mode 
    Does this mean I can't create my own QGraphicsView to be integrated with QDesigner? (because QGraphicsView does not directly inherit the QWidget class? Instead QGraphicsView inherits from QAbstractScrollArea) (?)
    Last edited by sincnarf; 12th October 2007 at 02:46. Reason: attach code of customgvPlugin
    Image Analysis Development Framework Using Qt (IADFUQ)

  5. #4
    Join Date
    Oct 2006
    Posts
    279
    Thanks
    6
    Thanked 40 Times in 39 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Can't create my custom QGraphicsView for QDesigner

    AFAICT you have to add
    Qt Code:
    1. QWidget *customgvPlugin::createWidget(QWidget *parent)
    2. {
    3. return new customgv(0, parent);
    4. }
    To copy to clipboard, switch view to plain text mode 

  6. The following user says thank you to spud for this useful post:

    sincnarf (12th October 2007)

  7. #5
    Join Date
    Apr 2007
    Posts
    117
    Thanks
    84
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Can't create my custom QGraphicsView for QDesigner

    Quote Originally Posted by spud View Post
    AFAICT you have to add
    Qt Code:
    1. QWidget *customgvPlugin::createWidget(QWidget *parent)
    2. {
    3. return new customgv(0, parent);
    4. }
    To copy to clipboard, switch view to plain text mode 
    same error still. I think I'm gonna give up on this
    Image Analysis Development Framework Using Qt (IADFUQ)

  8. #6
    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: Can't create my custom QGraphicsView for QDesigner

    createWidget has to return a QWidget pointer, not QGraphicsView pointer.

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

    sincnarf (12th October 2007)

  10. #7
    Join Date
    Apr 2007
    Posts
    117
    Thanks
    84
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Can't create my custom QGraphicsView for QDesigner

    Attached are all of the files for a custom QGraphicsView. Anyway if ever I succeed in this, how can I handle the includes for customgv.h that will be used by the designer? On compilation of my whole project there's an error in ui_mainwindow.h file of mine because of the line

    Qt Code:
    1. #include "customgv.h"
    To copy to clipboard, switch view to plain text mode 

    Also all lines like
    Qt Code:
    1. customgv *customgv;
    To copy to clipboard, switch view to plain text mode 
    in the ui_mainwindow.h will have errors. How will I solve this?
    Attached Files Attached Files
    Image Analysis Development Framework Using Qt (IADFUQ)

  11. #8
    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: Can't create my custom QGraphicsView for QDesigner

    What kind of error?

  12. #9
    Join Date
    Apr 2007
    Posts
    117
    Thanks
    84
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Can't create my custom QGraphicsView for QDesigner

    Quote Originally Posted by wysota View Post
    What kind of error?
    ui_mainwindow.h:68: error: ISO C++ forbids declaration of ‘customgv’ with no type
    ui_mainwindow.h:68: error: expected ‘;’ before ‘*’ token
    ui_mainwindow.h: In member function ‘void Ui_mainwindow::setupUi(QMainWindow*)’:
    ui_mainwindow.h:351: error: ‘customgv’ was not declared in this scope
    ui_mainwindow.h:351: error: expected type-specifier before ‘customgv’
    ui_mainwindow.h:351: error: expected `;' before ‘customgv’
    ui_mainwindow.h: In member function ‘void Ui_mainwindow::retranslateUi(QMainWindow*)’ :
    ui_mainwindow.h:850: error: ‘customgv’ was not declared in this scope
    Image Analysis Development Framework Using Qt (IADFUQ)

  13. #10
    Join Date
    Oct 2006
    Posts
    279
    Thanks
    6
    Thanked 40 Times in 39 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Can't create my custom QGraphicsView for QDesigner

    #include "‘customgv.h" is missing.

  14. The following user says thank you to spud for this useful post:

    sincnarf (15th October 2007)

  15. #11
    Join Date
    Apr 2007
    Posts
    117
    Thanks
    84
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Can't create my custom QGraphicsView for QDesigner

    Quote Originally Posted by spud View Post
    #include "‘customgv.h" is missing.
    see, whenever I execute "qmake" "make" .... the ui_mainwindow.h that comes from my mainwindow.ui is generated including the line "#include "customgv.h", so it's already there...

    What I need is this instead #include "../PLUGINS/customgvplugin/customgv.h" but alas, executing make generates the wrong path which is #include "customgv.h" only in my ui_mainwindow.h.

    So what I'm thinking right now is now that I've created my libcustomgvplugin.so plugin and it's aleady under the folder /usr/local/Trolltech/Qt-4.3.1/plugins/designer.... how can executing "make" not report errors like the ones stated above
    Last edited by sincnarf; 13th October 2007 at 09:06. Reason: rephrase
    Image Analysis Development Framework Using Qt (IADFUQ)

  16. #12
    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: Can't create my custom QGraphicsView for QDesigner

    You have to place the header file in some known location (just like regular headers are placed within /usr/include) and use the INCLUDEPATH+=-I<dir> statement in the project file of the project where you want to use the file.

    You can take a look at my wwWidgets to see how to solve some of your problems.

  17. The following user says thank you to wysota for this useful post:

    sincnarf (13th October 2007)

  18. #13
    Join Date
    Apr 2007
    Posts
    117
    Thanks
    84
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Can't create my custom QGraphicsView for QDesigner

    Quote Originally Posted by wysota View Post
    You can take a look at my wwWidgets to see how to solve some of your problems.
    Thanks but the site http://www.wysota.eu.org/wwwidgets is not loading.
    Image Analysis Development Framework Using Qt (IADFUQ)

  19. #14
    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: Can't create my custom QGraphicsView for QDesigner

    Try again tomorrow or on Monday, there seems to be a problem with the network link. I can do nothing about it now.

  20. The following user says thank you to wysota for this useful post:

    sincnarf (19th October 2007)

Similar Threads

  1. How to create Custom Slot upon widgets
    By ashukla in forum Qt Programming
    Replies: 6
    Last Post: 8th September 2007, 14:07
  2. Replies: 2
    Last Post: 12th July 2007, 09:55
  3. create custom widgets
    By nimmyj in forum General Discussion
    Replies: 1
    Last Post: 20th November 2006, 08:24
  4. Example HowTo create custom view
    By dexjam in forum Newbie
    Replies: 6
    Last Post: 12th July 2006, 11:06
  5. How to create custom slot in Qt Designer 4.1?
    By jamadagni in forum Qt Tools
    Replies: 31
    Last Post: 18th January 2006, 20:46

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.