本文整理汇总了C++中QtGradientStop类的典型用法代码示例。如果您正苦于以下问题:C++ QtGradientStop类的具体用法?C++ QtGradientStop怎么用?C++ QtGradientStop使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QtGradientStop类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: qRound
void QtGradientStopsWidgetPrivate::setupMove(QtGradientStop *stop, int x)
{
m_model->setCurrentStop(stop);
int viewportX = qRound(toViewport(stop->position()));
m_moveOffset = x - viewportX;
QList<QtGradientStop *> stops = m_stops;
m_stops.clear();
QListIterator<QtGradientStop *> itStop(stops);
while (itStop.hasNext()) {
QtGradientStop *s = itStop.next();
if (m_model->isSelected(s) || s == stop) {
m_moveStops[s] = s->position() - stop->position();
m_stops.append(s);
} else {
m_moveOriginal[s->position()] = s->color();
}
}
itStop.toFront();
while (itStop.hasNext()) {
QtGradientStop *s = itStop.next();
if (!m_model->isSelected(s))
m_stops.append(s);
}
m_stops.removeAll(stop);
m_stops.prepend(stop);
}
示例2: itStop
QGradientStops QtGradientStopsController::gradientStops() const
{
QGradientStops stops;
QList<QtGradientStop *> stopsList = d_ptr->m_model->stops().values();
QListIterator<QtGradientStop *> itStop(stopsList);
while (itStop.hasNext()) {
QtGradientStop *stop = itStop.next();
stops << QPair<qreal, QColor>(stop->position(), stop->color());
}
return stops;
}
示例3: while
QtGradientStopsControllerPrivate::PositionColorMap QtGradientStopsControllerPrivate::stopsData(const PositionStopMap &stops) const
{
PositionColorMap data;
PositionStopMap::ConstIterator itStop = stops.constBegin();
while (itStop != stops.constEnd()) {
QtGradientStop *stop = itStop.value();
data[stop->position()] = stop->color();
++itStop;
}
return data;
}
示例4: stopAt
QtGradientStop *QtGradientStopsWidgetPrivate::newStop(const QPoint &viewportPos)
{
QtGradientStop *copyStop = stopAt(viewportPos);
double posX = fromViewport(viewportPos.x());
QtGradientStop *stop = m_model->at(posX);
if (!stop) {
QColor newColor;
if (copyStop)
newColor = copyStop->color();
else
newColor = m_model->color(posX);
if (!newColor.isValid())
newColor = Qt::white;
stop = m_model->addStop(posX, newColor);
}
return stop;
}
示例5: itStop
QtGradientStop *QtGradientStopsWidgetPrivate::stopAt(const QPoint &viewportPos) const
{
double posY = m_handleSize / 2;
QListIterator<QtGradientStop *> itStop(m_stops);
while (itStop.hasNext()) {
QtGradientStop *stop = itStop.next();
double posX = toViewport(stop->position());
double x = viewportPos.x() - posX;
double y = viewportPos.y() - posY;
if ((m_handleSize * m_handleSize / 4) > (x * x + y * y))
return stop;
}
return 0;
}
示例6: QtGradientStop
QtGradientStop *QtGradientStopsModel::addStop(qreal pos, const QColor &color)
{
qreal newPos = pos;
if (pos < 0.0)
newPos = 0.0;
if (pos > 1.0)
newPos = 1.0;
if (d_ptr->m_posToStop.contains(newPos))
return 0;
QtGradientStop *stop = new QtGradientStop();
stop->setPosition(newPos);
stop->setColor(color);
d_ptr->m_posToStop[newPos] = stop;
d_ptr->m_stopToPos[stop] = newPos;
emit stopAdded(stop);
return stop;
}
示例7: slotUpdatePositionSpinBox
void QtGradientStopsControllerPrivate::slotUpdatePositionSpinBox()
{
QtGradientStop *current = m_model->currentStop();
if (!current)
return;
qreal min = 0.0;
qreal max = 1.0;
const qreal pos = current->position();
QtGradientStop *first = m_model->firstSelected();
QtGradientStop *last = m_model->lastSelected();
if (first && last) {
const qreal minPos = pos - first->position() - 0.0004999;
const qreal maxPos = pos + 1.0 - last->position() + 0.0004999;
if (max > maxPos)
max = maxPos;
if (min < minPos)
min = minPos;
if (first->position() == 0.0)
min = pos;
if (last->position() == 1.0)
max = pos;
}
const int spinMin = qRound(m_ui->positionSpinBox->minimum() * 1000);
const int spinMax = qRound(m_ui->positionSpinBox->maximum() * 1000);
const int newMin = qRound(min * 1000);
const int newMax = qRound(max * 1000);
m_ui->positionSpinBox->blockSignals(true);
if (spinMin != newMin || spinMax != newMax) {
m_ui->positionSpinBox->setRange((double)newMin / 1000, (double)newMax / 1000);
}
if (m_ui->positionSpinBox->value() != pos)
m_ui->positionSpinBox->setValue(pos);
m_ui->positionSpinBox->blockSignals(false);
}
示例8: currentStop
void QtGradientStopsModel::moveStops(double newPosition)
{
QtGradientStop *current = currentStop();
if (!current)
return;
double newPos = newPosition;
if (newPos > 1)
newPos = 1;
else if (newPos < 0)
newPos = 0;
if (newPos == current->position())
return;
double offset = newPos - current->position();
QtGradientStop *first = firstSelected();
QtGradientStop *last = lastSelected();
if (first && last) { // multiselection
double maxOffset = 1.0 - last->position();
double minOffset = -first->position();
if (offset > maxOffset)
offset = maxOffset;
else if (offset < minOffset)
offset = minOffset;
}
if (offset == 0)
return;
bool forward = (offset > 0) ? false : true;
PositionStopMap stopList;
QList<QtGradientStop *> selected = selectedStops();
QListIterator<QtGradientStop *> it(selected);
while (it.hasNext()) {
QtGradientStop *stop = it.next();
stopList[stop->position()] = stop;
}
stopList[current->position()] = current;
PositionStopMap::ConstIterator itStop = forward ? stopList.constBegin() : stopList.constEnd();
while (itStop != (forward ? stopList.constEnd() : stopList.constBegin())) {
if (!forward)
--itStop;
QtGradientStop *stop = itStop.value();
double pos = stop->position() + offset;
if (pos > 1)
pos = 1;
if (pos < 0)
pos = 0;
if (current == stop)
pos = newPos;
QtGradientStop *oldStop = at(pos);
if (oldStop && !stopList.values().contains(oldStop))
removeStop(oldStop);
moveStop(stop, pos);
if (forward)
++itStop;
}
}