I have a lots of troubles with the extern variable and to avoid this extern variable, i have try this:
foreach
(QColor color, colors
){ CMBcolor
[i
]->addItem
(QString::null,color
);
int index = CMBcolor[i]->count()-1;
pixmap.fill(color);
CMBcolor[i]->setItemData(index, pixmap, Qt::DecorationRole);
}
foreach(QColor color, colors){
CMBcolor[i]->addItem(QString::null,color);
int index = CMBcolor[i]->count()-1;
pixmap.fill(color);
CMBcolor[i]->setItemData(index, pixmap, Qt::DecorationRole);
}
To copy to clipboard, switch view to plain text mode
and fill all my combos correctly (I think this is more elegant). But when I want to know the clicked color i program (in other functions):
QColor col
= CMBcolor
[sup
]->itemData
(ncolor,Qt
::UserRole);
QColor col = CMBcolor[sup]->itemData(ncolor,Qt::UserRole);
To copy to clipboard, switch view to plain text mode
(ncolor is the currentitem in the combo, sup is the combo i have picked)
But I obtain an error. QColor is not QVariant. I have proved this:
QVariant col
= CMBcolor
[sup
]->itemData
(ncolor,Qt
::UserRole);
QVariant col = CMBcolor[sup]->itemData(ncolor,Qt::UserRole);
To copy to clipboard, switch view to plain text mode
and compile ok but how can i obtain the r chanel, g chanel and b chanel of the color from col.
Note that i would also have this problem with the other way too.
Bookmarks