Trolltech Home | Qt-solutions Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-solutions Archive, April 2008
QtVariantProperty and Icon Map


Message 1 in thread

Since the method QtVariantPropertyManager::iconMapType() exists, it should
be somehow possible to use icon maps in variant properties. However I can
not find any sample how it is done. I tried to provide a QMap<int,QIcon> as
value in the addAttribute method, however it cannot be converted to
QVariant.

 

Do I need to register a custom variant metatype (but how exactly?). Could
anybody provide a sample code snippet, please? 

 

Regards,

Acenes

 

 


Message 2 in thread

By checking the source of the variant property mgr I figured out how to pass
the map (see solution in the code below).

But allthough everything compiles and links fine, all the icons appear grey
instead of showing the brush styles. I guess I am doing something wrong here
in the icon creation:

QMap<int, QIcon> icons;
for (int style=Qt::NoBrush; style <= Qt::DiagCrossPattern; style++) {
	QIcon icon(QPixmap(16,16));
	QPainter painter;
	painter.setBrush((Qt::BrushStyle)style);
	icon.paint(&painter,0,0,16,16);
	icons[style] = icon;
} // for
prop->setAttribute(t_enumIcons, QVariant::fromValue(icons));


-- Acenes

--
 [ signature omitted ] 

Message 3 in thread

I am looking to embed a command-line shell into my Qt 4 app.  Does  
anyone know of a QWidget based command-line shell? Or perhaps a shell  
that can be embedded into a Qwidget?  I am looking for a solution for  
both windows and linux/unix/mac (separate solutions will work if  
required).

Thanks in advance,
-jim
------------------------
Jim Boyd
SciTools inc.
www.scitools.com

--
 [ signature omitted ] 

Message 4 in thread

Hi,

This mailing list is for Qt Solutions issues:
	http://trolltech.com/products/qt/addon/solutions/

Since this looks like a Qt question, I suggest trying the following mailing list:
	http://lists.trolltech.com/qt-interest/

-- 
 [ signature omitted ] 

Message 5 in thread

Ok, seems I am pretty much talking to myself on this list.
Anyway I figured out the icon creation and leave the final code snippet to
create a brush style property here in case someone else has the same
problem:

// brush.style
prop = mManager->addProperty(QtVariantPropertyManager::enumTypeId(),
t_style);

QStringList names;
names 
	<< tr("No Brush")
	<< tr("Solid")
	<< tr("Extremely dense")
	<< tr("Very dense")
	<< tr("Medium dense")
	<< tr("Half dense")
	<< tr("Sparse")
	<< tr("Very sparse")
	<< tr("Extremely sparse")
	<< tr("Horizontal lines")
	<< tr("Vertical lines")
	<< tr("Crossing")
	<< tr("Backward diagonal")
	<< tr("Forward diagonal")
	<< tr("Crossing diagonal");
prop->setAttribute(t_enumNames, names);

QMap<int, QIcon> icons;
for (int style=Qt::NoBrush; style <= Qt::DiagCrossPattern; style++) {
	QPixmap pixmap(32,32);
	pixmap.fill();
	QPainter painter(&pixmap);
	painter.setBrush((Qt::BrushStyle)style);
	painter.drawRect(1,1,30,30);
	icons[style] = QIcon(pixmap);
} // for
prop->setAttribute(t_enumIcons, QVariant::fromValue(icons));

group->addSubProperty(prop);


-- Acenes


--
 [ signature omitted ]