View Full Version : [Qt4 WinXP] Designer widget QTreeView problem

4th May 2006, 21:20
Hi, I'm trying to create a custom designer widget that derives from QTreeView, for QtDesigner. However, I'm getting the attached error messages whenever I try to drag it onto, and access it within, the QtDesigner. (I didn't know VS2005 was written using .NET) Has anyone run across this before?

My widget class is very bare bones - all it really does is publicly inherit QTreeView. I can post it if needed.

(edit: apologies about the attachment - failed to realize they had failed to post previously because of the 800x600 size limitation)

4th May 2006, 22:23
Where are those errors?

5th May 2006, 00:31
I tried adding an iconSize() and setIconSize() member to my class, but it didn't seem to have an effect. This doesn't seem to be an overridable method anyway, and should have been defined in the QAbstractItemView class, so I don't know why it's complaining there...

I've tried inheriting a different class as well - seems to also crash in the same way with QListView, but works okay if it inherits QPushButton.

Here's the header file fwcartview.h

#include <QObject>
#include <QTreeView>
#include <QtDesigner/QDesignerExportWidget>
class QDESIGNER_WIDGET_EXPORT FwCartView : public QTreeView
FwCartView(QWidget *parent = 0);

Here's the plugin cpp file fwcartviewplugin.cpp

#include "FwCartView.h"
#include "FwCartViewplugin.h"
#include <QtPlugin>
FwCartViewPlugin::FwCartViewPlugin(QObject *parent)
: QObject(parent) {
initialized = false;
void FwCartViewPlugin::initialize(QDesignerFormEditorIn terface *formEditor) {
if (initialized) {
initialized = true;
bool FwCartViewPlugin::isInitialized() const {
return initialized;

QWidget *FwCartViewPlugin::createWidget(QWidget *parent) {
return new FwCartView(parent);
QString FwCartViewPlugin::name() const {
return "FwCartView";
QString FwCartViewPlugin::group() const {
return "Leapfrog Widgets";

QIcon FwCartViewPlugin::icon() const {
return QIcon();

QString FwCartViewPlugin::toolTip() const {
return "FwCartView";
QString FwCartViewPlugin::whatsThis() const {
return "Custom cartridge view widget";

bool FwCartViewPlugin::isContainer() const {
return false;

QString FwCartViewPlugin::includeFile() const {
return "FwCartView.h";

QString FwCartViewPlugin::domXml() const {
return "<widget class=\"FwCartView\" name=\"fwCartView\">\n"
" <property name=\"geometry\">\n"
" <rect>\n"
" <x>0</x>\n"
" <y>0</y>\n"
" <width>100</width>\n"
" <height>25</height>\n"
" </rect>\n"
" </property>\n"
" <property name=\"toolTip\" >\n"
" <string>FwCartView</string>\n"
" </property>\n"
" <property name=\"whatsThis\" >\n"
" <string>Custom cartridge view to be used for "
"each page to be shown in the content pane</string>\n"
" </property>\n"
QString FwCartViewPlugin::codeTemplate() const {
return "";
Q_EXPORT_PLUGIN2(fwcartviewplugin, FwCartViewPlugin)

Here's fwcartview.cpp:

#include "FwCartView.h"
#include <QPainter>

FwCartView::FwCartView(QWidget *parent)
: QTreeView(parent)
setAttribute(Qt::WA_DeleteOnClose, true);

On a somewhat related note, Is there any way to debug designer widgets within QtDesigner? Since they have to be compiled in release mode, I guess the only way is to use qDebug() and look at the output or use QMessageBox's. Seems rather painful, as VS2005 has to be restarted and the plugin dll copied over to the plugin folder, everytime a change is made. Though I guess the widget can be debugged once the app is running, as it can link in the debug version of the designer widget dll...

9th May 2006, 16:35
What if you test the plugin against a standalone (without MSVS integration) Designer?