Results 1 to 3 of 3

Thread: No QCalendarWidget in designer? 4.2.0-tp1

  1. #1
    Join Date
    Apr 2006
    Posts
    40
    Thanks
    4
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default No QCalendarWidget in designer? 4.2.0-tp1

    I just grabbed the 4.2.0 technology preview, and I was looking for that new QCalendarWidget in designer, but it doesn't seem to be there. Is this only accessible via code? Or is that something that will be added to the designer later?

  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: No QCalendarWidget in designer? 4.2.0-tp1

    Probably Qt Designer just wasn't updated. You can always create a plugin yourself.

  3. #3
    Join Date
    Apr 2006
    Posts
    40
    Thanks
    4
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: No QCalendarWidget in designer? 4.2.0-tp1

    Indeed. I've never made a plug in before but it seemed fairly easy. Here's the code for it if anyone cares:

    calendarplugin.pro
    Qt Code:
    1. CONFIG += designer plugin debug_and_release
    2. TEMPLATE = lib
    3.  
    4. HEADERS = calendarplugin.h
    5. SOURCES = calendarplugin.cpp
    6.  
    7. target.path = $$[QT_INSTALL_PLUGINS]/designer
    8. INSTALLS += target
    To copy to clipboard, switch view to plain text mode 

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

    calendarplugin.cpp

    Qt Code:
    1. #include "calendarplugin.h"
    2. #include <QtPlugin>
    3. #include <QCalendarWidget>
    4.  
    5. CalendarPlugin::CalendarPlugin(QObject *parent)
    6. : QObject(parent)
    7. {
    8. initialized = false;
    9. }
    10.  
    11. void CalendarPlugin::initialize(QDesignerFormEditorInterface * /* core */)
    12. {
    13. if (initialized)
    14. return;
    15. initialized = true;
    16. }
    17.  
    18. bool CalendarPlugin::isInitialized() const
    19. {
    20. return initialized;
    21. }
    22.  
    23. QWidget *CalendarPlugin::createWidget(QWidget *parent)
    24. {
    25. return new QCalendarWidget(parent);
    26. }
    27.  
    28. QString CalendarPlugin::name() const
    29. {
    30. return "QCalendar";
    31. }
    32.  
    33. QString CalendarPlugin::group() const
    34. {
    35. return "Input Widgets";
    36. }
    37.  
    38. QIcon CalendarPlugin::icon() const
    39. {
    40. return QIcon();
    41. }
    42.  
    43. QString CalendarPlugin::toolTip() const
    44. {
    45. return "";
    46. }
    47.  
    48. QString CalendarPlugin::whatsThis() const
    49. {
    50. return "";
    51. }
    52.  
    53. bool CalendarPlugin::isContainer() const
    54. {
    55. return false;
    56. }
    57.  
    58. QString CalendarPlugin::domXml() const
    59. {
    60. return "<widget class=\"QCalendarWidget\" name=\"calendarWidget\">\n"
    61. " <property name=\"geometry\">\n"
    62. " <rect>\n"
    63. " <x>0</x>\n"
    64. " <y>0</y>\n"
    65. " <width>100</width>\n"
    66. " <height>100</height>\n"
    67. " </rect>\n"
    68. " </property>\n"
    69. " <property name=\"toolTip\" >\n"
    70. " <string>Show dates and pick one</string>\n"
    71. " </property>\n"
    72. " <property name=\"whatsThis\" >\n"
    73. " <string>The calendar widget allows "
    74. "a user to pick the current date.</string>\n"
    75. " </property>\n"
    76. "</widget>\n";
    77. }
    78.  
    79. QString CalendarPlugin::includeFile() const
    80. {
    81. return "qcalendarwidget.h";
    82. }
    83.  
    84. Q_EXPORT_PLUGIN2(calendarplugin, CalendarPlugin)
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Designer crashes when selecting some widgets
    By gwendal in forum Qt Tools
    Replies: 4
    Last Post: 21st July 2006, 13:18
  2. Adding slots in Designer
    By jamos in forum Qt Tools
    Replies: 5
    Last Post: 18th May 2006, 23:28
  3. Arthur Plugins demos and designer
    By antonio.r.tome in forum Installation and Deployment
    Replies: 4
    Last Post: 21st March 2006, 14:01
  4. Replies: 2
    Last Post: 14th February 2006, 15:28
  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.