No fill option in QColorDialog
-
if i have square in QGraphicsView and if I use this no color , the fill color of box should be set to its background just like clearing the box color fill color . Am I clear or shall I send a image for the same
-
@Qt-Enthusiast
Those white colors are custom colors :)
Its not for no color. -
@mrjj
and whats the difference between "no fill" and "transparancy" then?! -
@raven-worx
You are right,
its should give same effect ?But im not sure user will intuitively think, "ahh
if i lower Alpha to zero, it get rid of fill" :) -
Can someone write the code
-
@Qt-Enthusiast
Hi
@raven-worx showed you what to add to your color dialog.
colorDialog->setOption( QColorDialog::ShowAlphaChannel, true );
Then you get Alpha value.
User can set to zero and you get a transparent color which should look the same as no color. -
This is my code
can some one guide me how to do it hereconnect(this, SIGNAL(clicked(const QModelIndex&)), this, SLOT(clickedActivated(const QModelIndex&)));
}void myView::clickedActivated(const QModelIndex& index)
{
if (index.column() == 1 ) {
QColorDialog* colorDialog = new QColorDialog;
colorDialog->setOption(QColorDialog::ShowAlphaChannel, true );
QColor color = QColorDialog::getColor();
d_model->setData(index,color,Qt::DecorationRole);}
as I am getting compiltation error
-
QColorDialog colorDialog; colorDialog.setOption(QColorDialog::ShowAlphaChannel, true ); colorDialog.exec(); QColor color = colorDialog.getColor(); if( color.isValid() ) d_model->setData(index,color,Qt::DecorationRole);
-
I am using qt.4.3.3 I am getting following compliation error
error: ?class QColorDialog? has no member named ?setOption?
colorDialog.setOption(QColorDialog::ShowAlphaChannel, true );
error: ?ShowAlphaChannel? is not a member of ?QColorDialog?
colorDialog.setOption(QColorDialog::ShowAlphaChannel, true );my code is
void myInstView::clickedActivated(const QModelIndex& index)
{
if (index.column() == 1 ) {
QColorDialog colorDialog;
colorDialog.setOption(QColorDialog::ShowAlphaChannel, true );
colorDialog.exec();
QColor color = colorDialog.getColor();
if( color.isValid() )
model->setData(index,color,Qt::DecorationRole);
}}
} -
@Qt-Enthusiast
it seems it is only available since Qt 4.5 -
Can there be any alternative to it
-
@Qt-Enthusiast
Nope.
Fast way is to make new button or menu
that clear the color on the selected item.