View Full Version : Color Editor Factory Documentation

9th May 2011, 19:15
I'm following this (http://doc.trolltech.com/4.5/itemviews-coloreditorfactory.html) documentation page because I'm trying to implement a ColorComboBox Delegate of sorts to work over a custom data type (which recieves a QAbstractItemDelegate).

Thing is, this documentation page is either wrong or I'm just not getting it.

In http://doc.trolltech.com/4.5/itemviews-coloreditorfactory-window-cpp.html
that document, you can see something like this (at the very end)

setLayout(layout); setWindowTitle(tr("Color Editor Factory"));

That does not compile over a (reasonable from my PoV) "Identifier not found" error on "setLayout".

How can I fix that? this pointer doesn't provide a setLayout method.

How reliable are those documentation pages in general? It just so happens that that very documentation is EXACTLY what I need: A delegate for handling a color list selection.

9th May 2011, 19:19
Didn't you forgot the public in the window.h file at this line:

class Window : public QWidget //make sure you have 'public' inheritance

9th May 2011, 19:37
YES! Thank you!! This has been bugging me for like 2 hours now.

Too bad that, now, this points out something that's more likely than not a design flaw, because I now have a class signature like this,

class ColorlistDelegate : public QItemDelegate, public QWidget



9th May 2011, 20:04
I'm not a model-view expert, but i'm pretty sure you don't need that class to inherit from both QWidget and QItemDelegate.

LE: not all the classes have to inherit QWidget, the problem there was that only QWidgets have setLayout and if you just write class Window : QWidget means private inheritance and setLayout member function won't be accessible (since is private).

9th May 2011, 20:21
Thanks for the reply, thing is the GridTable I'm working with recieves QItemDelegate as parameter, thus this needs to inherit it to be "pass-able".

I'm working on a re-design and re-learning of the Delegate concept, right now, because I'm at a loss on how to properly make a ComboBox that displays a list of Colored Rect and Color name.

9th May 2011, 20:25
Yes you need to inherit from public QItemDelegate but i said that you don't need to inherit from QWidget.