PDA

View Full Version : Using <QColorDialog>



Gily
26th December 2007, 11:00
Hi all
I want to use <QColorDialog>
1)I added #include <QColorDialog>
2)I saw the function I need
QColor QColorDialog::getColor ( const QColor & initial = Qt::white, QWidget * parent = 0 ) [static] - in the QColorDialog Class Reference

3)I wrote QColor color = QColorDialog::getColor(const QColor & initial = Qt::white);

I get error message :

expected primary-expression before "const"

what do I do wrong?
I am also not dure what is the parent Widget, if I write it under one of the private slots (functions from the menu)

thanks!

wysota
26th December 2007, 11:33
You should pass the variable name not the function signature.

QColor color = QColorDialog::getColor(Qt::white);

Gily
26th December 2007, 16:35
funny me!! thanks

another question: how can I debug it and see what color selected?
if I want to add widget , what is the easiest way to do so? (I took "image viewer ' sample and added few functions)
I want to add another toolbar, and also another image window. id the best way to include in the main class, or do I better writwe a n ew class?
thanks

wysota
26th December 2007, 16:47
Debug what? The selected colour is assigned to the "color" variable of yours.

Gily
26th December 2007, 18:49
I know, but I want to do some color manipulation and see the result

jpn
26th December 2007, 21:26
Well, you can always print the color to debug output:


#include <QtDebug>
...
qDebug() << color;

Or you can fill a widget with the color so you can see it with your own eyes:

widget->setStyleSheet(QString("background: %1").arg(color.name()));