try to fix vcx proj
This commit is contained in:
@@ -183,6 +183,7 @@ bool XQItem::hasContentNode() const
|
||||
XQItem& firstItem = xqItemFromIndex( pIndex );
|
||||
return firstItem.hasContentNode();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//! gibt den content-node zurück.
|
||||
|
@@ -86,6 +86,7 @@ void XQItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option
|
||||
{
|
||||
case XQItem::HeaderStyle :
|
||||
return drawHeaderStyle( painter, option, item );
|
||||
//return drawHeaderStyleX( painter, option, index );
|
||||
|
||||
case XQItem::ComboBoxStyle :
|
||||
return drawComboBoxStyle( painter, option, item );
|
||||
@@ -93,9 +94,9 @@ void XQItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option
|
||||
case XQItem::ColorBarStyle :
|
||||
return drawColorBarStyle( painter, option, item );
|
||||
|
||||
// das funktioniert nicht unter windows11
|
||||
//case XQItem::SpinBoxStyle :
|
||||
// return drawSpinBoxStyle( painter, option, item );
|
||||
// das funktioniert nicht unter windows11
|
||||
//case XQItem::SpinBoxStyle :
|
||||
// return drawSpinBoxStyle( painter, option, item );
|
||||
|
||||
case XQItem::HiddenStyle :
|
||||
return;
|
||||
@@ -119,49 +120,32 @@ void XQItemDelegate::drawHeaderStyle(QPainter* painter, const QStyleOptionViewIt
|
||||
{
|
||||
QStyleOptionHeader headerOption;
|
||||
|
||||
/*
|
||||
QWidget* srcWidget = nullptr;
|
||||
const QTreeView* treeView = qobject_cast<const QTreeView*>(option.widget);
|
||||
if (treeView != nullptr)
|
||||
{
|
||||
srcWidget = (QWidget*)treeView;
|
||||
// is never nullptr !?
|
||||
if (treeView->header() != nullptr)
|
||||
{
|
||||
// use the header as "parent" for style init
|
||||
srcWidget = treeView->header();
|
||||
}
|
||||
headerOption.initFrom(srcWidget);
|
||||
headerOption.text = "FIRZ";//index.data(Qt::DisplayRole).toString();
|
||||
headerOption.rect = option.rect;
|
||||
headerOption.styleObject = option.styleObject;
|
||||
// __ch: reduce inner offset when painting
|
||||
headerOption.textAlignment |= Qt::AlignVCenter;
|
||||
|
||||
// --
|
||||
}
|
||||
*/
|
||||
|
||||
// use the header as "parent" for style init
|
||||
QWidget* srcWidget = treeTable();//->header();
|
||||
headerOption.initFrom(srcWidget);
|
||||
headerOption.text = item.text();
|
||||
headerOption.rect = option.rect.adjusted(0,0,0,3);
|
||||
headerOption.text = item.text();//index.data(Qt::DisplayRole).toString();
|
||||
headerOption.rect = option.rect;//.adjusted(0,0,0,3);
|
||||
headerOption.styleObject = option.styleObject;
|
||||
// __ch: reduce inner offset when painting
|
||||
headerOption.textAlignment |= Qt::AlignVCenter;
|
||||
headerOption.icon = item.icon();
|
||||
|
||||
|
||||
// save painter
|
||||
painter->save();
|
||||
//value = index.data(Qt::ForegroundRole);
|
||||
//if (value.canConvert<QBrush>())
|
||||
//headerOption.palette.setBrush(QPalette::Text, Qt::red );
|
||||
//headerOption.palette.setBrush(QPalette::Window, Qt::red );
|
||||
//QCommonStyle itemStyle;
|
||||
|
||||
|
||||
QStyle* widgetStyle = srcWidget->style();
|
||||
QApplication::style()->drawControl(QStyle::CE_Header, &headerOption, painter, srcWidget);
|
||||
//qApp->style()->drawControl(QStyle::CE_Header, &headerOption, painter, srcWidget);
|
||||
//srcWidget->style()->drawControl(QStyle::CE_Header, &headerOption, painter, srcWidget);
|
||||
// warum das nur mit dem commonstyle, ist mir echt unklar.
|
||||
_commonStyle.drawControl(QStyle::CE_Header, &headerOption, painter, srcWidget);
|
||||
// restore painter
|
||||
painter->restore();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -186,14 +170,12 @@ void XQItemDelegate::drawColorBarStyle(QPainter* painter, const QStyleOptionView
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
QRect barRect(rect.left(), rect.top(), barWidth, rect.height());
|
||||
QColor barColor = QColor(100, 180, 255); // z. B. hellblau
|
||||
QColor barColor = QColor(100, 180, 255);
|
||||
painter->setBrush(barColor);
|
||||
painter->setPen(Qt::NoPen);
|
||||
painter->drawRect(barRect);
|
||||
|
||||
// Text (Zahl) zentriert zeichnen
|
||||
painter->setPen(Qt::black);
|
||||
//painter->drawText(rect, Qt::AlignCenter, QString::number(value)+" %");
|
||||
painter->drawText(rect, Qt::AlignCenter, item.text() );
|
||||
|
||||
painter->restore();
|
||||
@@ -222,6 +204,8 @@ void XQItemDelegate::drawComboBoxStyle(QPainter* painter, const QStyleOptionView
|
||||
|
||||
// save painter
|
||||
painter->save();
|
||||
|
||||
// hier wiederum funktioniert der '_commonStyle' nicht
|
||||
QStyle* widgetStyle = srcWidget->style();
|
||||
// draw combo
|
||||
widgetStyle->drawComplexControl(QStyle::CC_ComboBox, &comboOption, painter, srcWidget);
|
||||
@@ -244,8 +228,6 @@ void XQItemDelegate::drawSpinBoxStyle(QPainter* painter, const QStyleOptionViewI
|
||||
QStyleOptionSpinBox spinBoxOption;
|
||||
spinBoxOption.initFrom(srcWidget);
|
||||
|
||||
|
||||
// 1. Grundlegende Optionen initialisieren und Hintergrund zeichnen (wichtig für Selektion)
|
||||
initStyleOption(&viewOption, item.index());
|
||||
if (option.state & QStyle::State_HasFocus)
|
||||
{
|
||||
@@ -253,16 +235,15 @@ void XQItemDelegate::drawSpinBoxStyle(QPainter* painter, const QStyleOptionViewI
|
||||
}
|
||||
QApplication::style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &viewOption, painter);
|
||||
|
||||
spinBoxOption.rect = option.rect;
|
||||
spinBoxOption.rect = option.rect;//.adjusted( 0,0,-40,0);
|
||||
spinBoxOption.state = option.state | QStyle::State_Sunken; // Sunken-State für den "LineEdit"-Look
|
||||
spinBoxOption.buttonSymbols = QAbstractSpinBox::UpDownArrows;
|
||||
spinBoxOption.stepEnabled = QAbstractSpinBox::StepUpEnabled | QAbstractSpinBox::StepDownEnabled;
|
||||
spinBoxOption.frame = true;
|
||||
|
||||
QStyle* widgetStyle = srcWidget->style();
|
||||
widgetStyle->drawComplexControl(QStyle::CC_SpinBox, &spinBoxOption, painter, nullptr);
|
||||
QRect editRect = widgetStyle->subControlRect(QStyle::CC_SpinBox, &spinBoxOption, QStyle::SC_SpinBoxEditField, nullptr);
|
||||
painter->drawText(editRect.adjusted(1, 0, -1, 0), Qt::AlignCenter, item.text());
|
||||
_commonStyle.drawComplexControl(QStyle::CC_SpinBox, &spinBoxOption, painter, nullptr);
|
||||
QRect editRect =_commonStyle.subControlRect(QStyle::CC_SpinBox, &spinBoxOption, QStyle::SC_SpinBoxEditField, nullptr);
|
||||
painter->drawText(spinBoxOption.rect, Qt::AlignCenter, item.text());
|
||||
|
||||
}
|
||||
|
||||
|
@@ -16,6 +16,7 @@
|
||||
#define XQITEMDELEGATE_H
|
||||
|
||||
#include <QStyledItemDelegate>
|
||||
#include <QCommonStyle>
|
||||
#include <xqappdata.h>
|
||||
|
||||
class XQItem;
|
||||
@@ -52,6 +53,7 @@ protected:
|
||||
void drawSpinBoxStyle(QPainter* painter, const QStyleOptionViewItem& option, const XQItem& item) const;
|
||||
|
||||
XQViewModel& _modelView;
|
||||
QCommonStyle _commonStyle;
|
||||
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user