本文整理汇总了C++中QTreeWidgetItem::backgroundColor方法的典型用法代码示例。如果您正苦于以下问题:C++ QTreeWidgetItem::backgroundColor方法的具体用法?C++ QTreeWidgetItem::backgroundColor怎么用?C++ QTreeWidgetItem::backgroundColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTreeWidgetItem
的用法示例。
在下文中一共展示了QTreeWidgetItem::backgroundColor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gradientStops
/** Returns list of GradientStops corresponding content of tree widget.
* \sa setGradientStops()
*/
QGradientStops GradientEditWidget::gradientStops() const {
QGradientStops result(treeWidget->topLevelItemCount());
for (int i=0; i<result.size(); i++) {
QTreeWidgetItem *item = treeWidget->topLevelItem(i);
QGradientStop stop(item->text(0).toDouble(), item->backgroundColor(1));
result[i] = stop;
}
return result;
}
示例2: assignColorFromSMVTreeWidget
void FeatureTreeWidget::assignColorFromSMVTreeWidget(QString featureName)
{
QTreeWidgetItem *item = getItemFromFeatureName(featureName);
if (item!=0)
{
if (item->childCount()==0){
mainWindow->questionDialog->writeToLog("assignColor<1>");
Feature *f = getCorrespondingFeature(featureName);
Color *c = static_cast<MyListWidgetItem*>(listWidget->selectedItems().at(0))->getBGColor();
if (item->backgroundColor(0).isValid())
mainWindow->removeColorAssignment(static_cast<MyTreeWidgetItem*>(item));
colorManager->setColorForFeature(f,c);
//X zum Abwählen der Farbe setzen
if (itemWidget(item, 1))
itemWidget(item, 1)->show();
else{
QToolButton *deleteButton = new QToolButton(this);
deleteButton->setFont(QFont(QString("MS Shell Dlg 2"),9,10,false));
//deleteButton->setFixedSize(15,18);
deleteButton->setFixedWidth(16);
QIcon icon = QIcon();
icon.addPixmap(QPixmap(QString(":/images/cross.png")),QIcon::Normal,QIcon::On);
deleteButton->setIcon(icon);
deleteButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
setItemWidget(item,1,deleteButton);
connect(deleteButton,SIGNAL(clicked()),this,SLOT(removeColorAssignment()));
}
//aktualisiere SmvTreeWidget und TextEdit
mainWindow->updateSMVTreeTexture(f);
redrawListWidget();
//wenn Farbe schon in FeatureTreeWidget vorhanden, setze diese auf weiß/transparent
QList <QTreeWidgetItem*> *treeList = new QList <QTreeWidgetItem*>();
findBackGroundColor(c->color,root,treeList);
if (treeList->isEmpty()==false)
{
for (int i = 0;i < treeList->size();i++){
static_cast<MyTreeWidgetItem*>(treeList->at(i))->setBackgroundInvalid();
// treeList->at(i)->background(0).setStyle(Qt::NoBrush);
// treeList->at(i)->setBackgroundColor(0,QColor(0,0,0,0));
colorManager->deleteColorForFeature(getCorrespondingFeature(treeList->at(i)->text(0)));
}
}
//setze Farbe im FeatureTreeWidget
static_cast<MyTreeWidgetItem*>(item)->setBGColor(c);
//item->setBackgroundColor(0,selected->color);
}
}
}
示例3: dropEvent
void FeatureTreeWidget::dropEvent(QDropEvent *event)
{
//Darstellen des Drag-Bildes
QByteArray itemData = event->mimeData()->data("application/x-dnditemdata");
QDataStream dataStream(&itemData, QIODevice::ReadOnly);
QPixmap pixmap;
QPoint offset;
dataStream >> pixmap >> offset;
QTreeWidgetItem *item = itemAt(event->pos().x(),event->pos().y());
//wenn auf ein TreeWidgetItem gedropt und dieses ein Blattknoten ist
if (item!=0)
{
if (item->childCount()==0){
mainWindow->questionDialog->writeToLog("assignColor<1>");
Feature *f = getCorrespondingFeature(item->text(0));
//Color *c = new Color (selected->color.convertTo(QColor::Hsv));
Color *c = static_cast<MyListWidgetItem*>(listWidget->selectedItems().at(0))->getBGColor();
if (item->backgroundColor(0).isValid())
mainWindow->removeColorAssignment(static_cast<MyTreeWidgetItem*>(item));
colorManager->setColorForFeature(f,c);
//X zum Abwählen der Farbe setzen
if (itemWidget(item, 1))
itemWidget(item, 1)->show();
else{
QToolButton *deleteButton = new QToolButton(this);
deleteButton->setFont(QFont(QString("MS Shell Dlg 2"),9,10,false));
//deleteButton->setFixedSize(15,18);
deleteButton->setFixedWidth(16);
QIcon icon = QIcon();
icon.addPixmap(QPixmap(QString(":/images/cross.png")),QIcon::Normal,QIcon::On);
deleteButton->setIcon(icon);
deleteButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
setItemWidget(item,1,deleteButton);
connect(deleteButton,SIGNAL(clicked()),this,SLOT(removeColorAssignment()));
}
//aktualisiere SmvTreeWidget und TextEdit
mainWindow->updateSMVTreeTexture(f);
redrawListWidget();
//wenn Farbe schon in FeatureTreeWidget vorhanden, setze diese auf weiß/transparent
QList <QTreeWidgetItem*> *treeList = new QList <QTreeWidgetItem*>();
findBackGroundColor(c->color,root,treeList);
if (treeList->isEmpty()==false)
{
for (int i = 0;i < treeList->size();i++){
static_cast<MyTreeWidgetItem*>(treeList->at(i))->setBackgroundInvalid();
// treeList->at(i)->background(0).setStyle(Qt::NoBrush);
// treeList->at(i)->setBackgroundColor(0,QColor(0,0,0,0));
colorManager->deleteColorForFeature(getCorrespondingFeature(treeList->at(i)->text(0)));
}
}
//setze Farbe im FeatureTreeWidget
static_cast<MyTreeWidgetItem*>(item)->setBGColor(c);
//item->setBackgroundColor(0,selected->color);
}
event->ignore();
}
}