[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: KConfig and multiple values
From: "David Boosalis" <david.boosalis () gmail ! com>
Date: 2007-07-13 14:09:05
Message-ID: 870c99310707130709m2af6257cg5a6fbc3377c54276 () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
How about using QMap to create some thinkg like:
QMap <QString,QColor> colorMap;
colorMap["black"]=QColor::black;
colorMap["red"] = QColor(255,0,0);
colorMap["white'"] = QColor::white;
Then create a class that inherits from QLisWidgetItem
Class ColorListItem : public QListWidgetItem
{
public:
ColorListtItem(QListWidget *parent,QColor &kolor,QString &name);
private:
QColor color;
QString text;
};
THen of course you just have to implement the paintEvent in a widget that
inherits from QListView.
Okay the colorMap has nothing to do with ColorListItem, but if you need the
colors on more then one area, it would be a good way to keep track of them
-David
On 7/13/07, David Jarvie <lists@astrojar.org.uk> wrote:
>
> On Wednesday 11 July 2007 23:25, Yannick Gingras wrote:
> >
> >> On Wednesday 11 July 2007, Yannick Gingras wrote:
> >>> I want to implement a list of configuration settings in my
> application.
> >>
> >> not exactly sure what you want given your description. is what you want
> >> something like an array of structs? e.g.: [snip]
> >
> > What I want is an array of colors. The colors would be presented in a
> > listview and stored sequentially:
> >
> > [NickColors]
> > #ffbbff
> > #ffbbff
> > #fabbff
> > ...
> > #b3b3b3
> >
> > I want to use a listview rather than buttons like most people do because
> I
> > want 50+ colors. The number of colors would also be variable.
>
> You could create a QStringList containing the all the colours (use
> QColor::name() to get each individual colour string). KConfig* reads and
> writes a QStringList entry in the format
>
> NickColors=#ffbbff,#ffbbff,...,#b3b3b3
>
> --
> David Jarvie.
> KAlarm author & maintainer.
> http://www.astrojar.org.uk/kalarm
>
>
> >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to
> unsubscribe <<
>
[Attachment #5 (text/html)]
How about using QMap to create some thinkg like:<br> QMap <QString,QColor> \
colorMap;<br>colorMap["black"]=QColor::black;<br>colorMap["red"] \
= QColor(255,0,0);<br>colorMap["white'"] = QColor::white; \
<br><br><br>Then create a class that inherits from QLisWidgetItem<br><br>Class \
ColorListItem : public QListWidgetItem<br>{<br> \
public:<br> ColorListtItem(QListWidget *parent,QColor \
&kolor,QString &name);<br> \
private:<br> QColor \
color;<br> QString text;<br>};<br><br>THen \
of course you just have to implement the paintEvent in a widget that inherits from \
QListView.<br><br>Okay the colorMap has nothing to do with ColorListItem, but if you \
need the colors on more then one area, it would be a good way to keep track of them \
<br><br>-David<br><br><br><br><div><span class="gmail_quote">On 7/13/07, <b \
class="gmail_sendername">David Jarvie</b> <<a \
href="mailto:lists@astrojar.org.uk">lists@astrojar.org.uk</a>> \
wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, \
204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> On Wednesday 11 July 2007 \
23:25, Yannick Gingras wrote:<br>><br>>> On Wednesday 11 July 2007, Yannick \
Gingras wrote:<br>>>> I want to implement a list of configuration settings \
in my application.<br>>> <br>>> not exactly sure what you want given your \
description. is what you want<br>>> something like an array of structs? e.g.: \
[snip]<br>><br>> What I want is an array of colors. The colors would \
be presented in a <br>> listview and stored sequentially:<br>><br>> \
[NickColors]<br>> #ffbbff<br>> #ffbbff<br>> #fabbff<br>> ...<br>> \
#b3b3b3<br>><br>> I want to use a listview rather than buttons like most people \
do because I <br>> want 50+ colors. The number of colors would also be \
variable.<br><br>You could create a QStringList containing the all the colours \
(use<br>QColor::name() to get each individual colour string). KConfig* reads and \
<br>writes a QStringList entry in the \
format<br><br>NickColors=#ffbbff,#ffbbff,...,#b3b3b3<br><br>--<br>David \
Jarvie.<br>KAlarm author & maintainer.<br><a \
href="http://www.astrojar.org.uk/kalarm">http://www.astrojar.org.uk/kalarm \
</a><br><br><br>>> Visit <a \
href="http://mail.kde.org/mailman/listinfo/kde-devel#unsub">http://mail.kde.org/mailman/listinfo/kde-devel#unsub</a> \
to unsubscribe <<<br></blockquote></div><br>
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic