本文整理汇总了C++中QColorDialog::currentColor方法的典型用法代码示例。如果您正苦于以下问题:C++ QColorDialog::currentColor方法的具体用法?C++ QColorDialog::currentColor怎么用?C++ QColorDialog::currentColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QColorDialog
的用法示例。
在下文中一共展示了QColorDialog::currentColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: slotOpenColorEditor
void PropertiesEditorItem::slotOpenColorEditor()
{
QColorDialog *dialog = new QColorDialog(parent());
dialog->setCurrentColor(mProperty.read(mObject.data()).value<QColor>());
if (dialog->exec() == QDialog::Accepted) {
mProperty.write(mObject.data(), QVariant::fromValue(dialog->currentColor()));
QPushButton *button = qobject_cast<QPushButton*>(mWidget.data());
button->setText(dialog->currentColor().name());
}
delete dialog;
}
示例2: eventFilter
bool VpGridDialog::eventFilter(QObject *obj, QEvent *ev)
{
if ((obj == m_ui->colorWell) || (obj == m_ui->referenceColorWell))
{
if (ev->type() == QEvent::MouseButtonRelease)
{
//QMouseEvent *event = static_cast<QMouseEvent*>(ev);
QColorDialog *colorDialog = new QColorDialog();
if (obj == m_ui->colorWell)
// Modify grid color.
colorDialog->setCurrentColor(getColor());
else
// Modify reference color.
colorDialog->setCurrentColor(getReferenceColor());
int retValue = colorDialog->exec();
if (retValue == QDialog::Accepted)
{
QColor selectedColor = colorDialog->currentColor();
if (obj == m_ui->colorWell)
// Modify grid color.
setColor(selectedColor);
else
// Modify reference color.
setReferenceColor(selectedColor);
}
delete colorDialog;
return true;
} else {
return false;
}
} else {
// Pass the event on to the parent class.
return QDialog::eventFilter(obj, ev);
}
}
示例3: setNodeLabelColor
void NodeConfigurationDialog::setNodeLabelColor(void)
{
if (!graph)
return;
if (!graph->numValidNodes) {
QMessageBox::information(this, tr("A Serious Lack of Nodes"), tr("No nodes to configure yet, sorry."));
return;
}
QColor clr(
graph->nodes[0].labelColor.r,
graph->nodes[0].labelColor.g,
graph->nodes[0].labelColor.b,
graph->nodes[0].labelColor.a);
QColorDialog *d = new QColorDialog(clr, this);
d->setOption(QColorDialog::ShowAlphaChannel, true);
d->exec();
if (QDialog::Accepted==d->result()) {
clr=d->currentColor();
watcher::Color c(clr.red(), clr.green(), clr.blue(), clr.alpha());
QString ss;
ss.sprintf("background-color: #%02x%02x%02x; color: #%02x%02x%02x",
clr.red(), clr.green(), clr.blue(),
(~clr.red())&0xFF, (~clr.green())&0xFF, (~clr.blue())&0xFF);
labelColorButton->setStyleSheet(ss);
if (useNodeId)
graph->nodes[curNodeId].labelColor=c;
else
for (size_t n=0; n<graph->numValidNodes; n++)
graph->nodes[n].labelColor=c;
}
}
示例4: onSelectorClicked
void AdvancedSettings::onSelectorClicked()
{
int emitter = getEmitter (QObject::sender());
/* Configure the color dialog */
QString color;
QColorDialog dialog;
dialog.setCurrentColor (getColor (emitter));
dialog.setOption (QColorDialog::DontUseNativeDialog);
/* Get new color */
if (dialog.exec() == QColorDialog::Accepted)
color = QVariant (dialog.currentColor()).toString();
/* User clicked the 'Cancel' button in the color dialog */
else
return;
/* Update the line edit that matches the button that called this function */
switch (emitter) {
case Base:
ui.BaseEdit->setText (color);
break;
case Highlight:
ui.HighlightEdit->setText (color);
break;
case Background:
ui.BackgroundEdit->setText (color);
break;
case Foreground:
ui.ForegroundEdit->setText (color);
break;
}
}
示例5: slotClicked
void ColorEditor::slotClicked()
{
m_buttonPressed = true;
QColorDialog* dialog = new QColorDialog(this);
dialog->setCurrentColor(m_color);
if (dialog->exec()) m_color=dialog->currentColor();
delete dialog;
setFocusToParent();
emit(editingFinished());
}
示例6: on_pushButtonBackgroundColor_clicked
void CWizPreferenceWindow::on_pushButtonBackgroundColor_clicked()
{
QColorDialog dlg;
dlg.setCurrentColor(m_app.userSettings().editorBackgroundColor());
if (dlg.exec() == QDialog::Accepted)
{
QString strColor = dlg.currentColor().name();
updateEditorBackgroundColor(strColor);
}
}
示例7: colorDialog
void SettingsDlg::colorDialog( const char * optionName, QString title )
{
QColorDialog dlg;
dlg.setWindowTitle(title);
dlg.setCurrentColor( getColor( optionName, 0x000000 ) );
if ( dlg.exec() == QDialog::Accepted ) {
setColor( optionName, dlg.currentColor() );
updateStyleSample();
}
}
示例8: backGroundChanged
void ChatBrowser::backGroundChanged()
{
QColorDialog dialog;
dialog.setCurrentColor(m_bgColor);
if(dialog.exec()==QDialog::Accepted)
{
m_bgColor=dialog.currentColor();
setStyleSheet(QString("QTextBrowser { background:%1;}").arg(m_bgColor.name()));
}
}
示例9: on_waveView_doubleClicked
void PreferencesDialog::on_waveView_doubleClicked(const QModelIndex &index)
{
if (index.column() == 1) {
QColorDialog a;
if (!(index.flags() & Qt::ItemIsEnabled)) return;
quint32 color = index.data(Qt::UserRole).toUInt();
a.setCurrentColor(QColor((QRgb)color));
if (a.exec() == QColorDialog::Accepted) {
quint32 cv = a.currentColor().rgba();
waveFilterModel->setData(index, cv, Qt::UserRole);
waveFilterModel->setData(index, a.currentColor(), Qt::BackgroundRole);
}
}
}
示例10:
void MainWindow::on_actionSet_background_color_2_triggered()
{
QColorDialog dialog;
dialog.setCurrentColor(mBackgroundColor);
int result = dialog.exec();
if (result)
{
mBackgroundColor = dialog.currentColor();
}
}
示例11: on_pushButtonSelectColor_clicked
void QReportPropertyPageLineType::on_pushButtonSelectColor_clicked()
{
QColorDialog *dlg = new QColorDialog();
dlg->exec();
QPalette palette;
QBrush brush( dlg->currentColor() );
brush.setStyle(Qt::SolidPattern);
palette.setBrush(QPalette::Active, QPalette::Base, brush);
palette.setBrush(QPalette::Inactive, QPalette::Base, brush);
textBrowserColorBox->setPalette(palette);
//textBrowserColorBox->palette().setColor( QPalette::Base, dlg->currentColor() );
}
示例12: QColorDialog
void Control3DWidget::onLightColorPicker()
{
QColorDialog* pDialog = new QColorDialog(this);
pDialog->setCurrentColor(m_colCurrentLightColor);
//Update all connected View3D's scene colors
connect(pDialog, &QColorDialog::currentColorChanged,
this, &Control3DWidget::onLightColorChanged);
pDialog->exec();
m_colCurrentLightColor = pDialog->currentColor();
//Set color of button new new scene color
ui->m_pushButton_lightColorPicker->setStyleSheet(QString("background-color: rgb(%1, %2, %3);").arg(m_colCurrentLightColor.red()).arg(m_colCurrentLightColor.green()).arg(m_colCurrentLightColor.blue()));
}
示例13: on_toolButtonChangeColorLink_clicked
void CDialogIrcSettings::on_toolButtonChangeColorLink_clicked()
{
QColorDialog* dlgColor = new QColorDialog( this );
dlgColor->setCurrentColor( m_ColorLink );
int result = dlgColor->exec();
if ( result == QDialog::Accepted )
{
m_ColorLink = dlgColor->currentColor();
ui->labelColorLink->setStyleSheet( QString( "background-color: %1;" ).arg( m_ColorLink.name() ) );
ui->pushButtonApply->setEnabled( true );
}
}
示例14: setModelData
//--------------------------------------------------------------------------------------
void RMapObjectTableViewDelegate::setModelData(QWidget *editor,
QAbstractItemModel *model,
const QModelIndex &index) const
{
switch (index.data(Qt::UserRole).toInt()) {
case RMapObjectModel::ET_COLOR_SELECTOR: {
QColorDialog *colorbox = static_cast<QColorDialog *>(editor);
if (colorbox->result() == QDialog::Accepted) {
QColor color = colorbox->currentColor();
model->setData(index, color, Qt::EditRole);
}
break;
}
case RMapObjectModel::ET_FONT_SELECTOR: {
RFontSelectorDialog *fontSelector = static_cast<RFontSelectorDialog *>(editor);
if (fontSelector->result() == QDialog::Accepted) {
const RFontDescriptor *fd = fontSelector->currentFontDescriptor();
model->setData(index, qVariantFromValue(fd), Qt::EditRole);
}
break;
}
case RMapObjectModel::ET_PICTURE_SELECTOR: {
RPictureSelectorDialog *pictureSelector = static_cast<RPictureSelectorDialog *>(editor);
if (pictureSelector->result() == QDialog::Accepted) {
const RImageDescriptor *id = pictureSelector->currentImageDescriptor();
model->setData(index, qVariantFromValue(id), Qt::EditRole);
}
break;
}
case RMapObjectModel::ET_REFS_SELECTOR: {
QComboBox *refsSelector = static_cast<QComboBox *>(editor);
int row = refsSelector->currentIndex();
int data = refsSelector->itemData(row).toInt();
const RRefsDescriptor *rd = &RMapRegistry::instance().getRefsDescriptorById(data);
model->setData(index, qVariantFromValue(rd), Qt::EditRole);
break;
}
default:
QItemDelegate::setModelData(editor, model, index);
break;
}
}
示例15: pickColor
void ColorsIcon::pickColor(QPalette::ColorRole role)
{
// TODO: QColorDialog is bugged. Corrupts alpha when no adjustment occurs.
QColorDialog dlg;
dlg.setOption(QColorDialog::DontUseNativeDialog);
dlg.setOption(QColorDialog::ShowAlphaChannel);
dlg.setCurrentColor(role == QPalette::Foreground ? mPen : mBrush);
dlg.setWindowTitle(role == QPalette::Foreground ?
tr("Select pen color") :
tr("Select brush color"));
// Execute dialog
if(dlg.exec() == QDialog::Accepted) {
// Emit color change
emit colorPicked(role, dlg.currentColor());
}
}