[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-look
Subject: Radio button group highlighting (was: UI feedback from a Linux newbie)
From: Rik Hemsley <rik () kde ! org>
Date: 2000-04-18 14:15:55
[Download RAW message or body]
#if Dirk Hennig
> > Agreed. I haven't come across users that are confused by this, but the
> > affirmative nature of the tick or check certainly makes more sense than
> > the cross which has negative connotations.
>
> I also agree with this.
> But I think, the difference in look between check- and radiobuttons should be greater than
> the shape of them. It would be great, if the connection between the radioboxes could be
> shown. No real computer newie knows, that round shape means, that only one of the options
> can be enabled. Some sort of slider would be much better.
I just tried to do something that shows that radio buttons are
connected.
It's quite ugly, but it shows one possibility anyway.
Have fun with it ;)
I compiled it with:
moc -o radiotest.moc radiotest.cpp ; g++ -o radiotest radiotest.cpp -I$QTDIR/include -L$QTDIR/lib -lqt
Rik
["radiotest.cpp" (text/plain)]
#include <qlist.h>
#include <qradiobutton.h>
#include <qbuttongroup.h>
#include <qapplication.h>
#include <qlayout.h>
class MyRadio : public QRadioButton
{
Q_OBJECT
public:
MyRadio(const QString & text, QWidget * parent)
: QRadioButton(text, parent),
highlighted_(false)
{
connect(this, SIGNAL(entered()), parent, SLOT(entered()));
connect(this, SIGNAL(left()), parent, SLOT(left()));
originalMode_ = backgroundMode();
}
void highlight(bool b)
{
setBackgroundMode(b ? PaletteLight : originalMode_);
}
signals:
void entered();
void left();
protected:
virtual void enterEvent(QEvent * e)
{
QRadioButton::enterEvent(e);
emit(entered());
}
virtual void leaveEvent(QEvent * e)
{
QRadioButton::leaveEvent(e);
emit(left());
}
private:
bool highlighted_;
BackgroundMode originalMode_;
};
class MyWidget : public QWidget
{
Q_OBJECT
public:
MyWidget()
: QWidget(0)
{
MyRadio * rb1 = new MyRadio("Option One", this);
MyRadio * rb2 = new MyRadio("Option Two", this);
MyRadio * rb3 = new MyRadio("Option Three", this);
buttonList.append(rb1);
buttonList.append(rb2);
buttonList.append(rb3);
QButtonGroup * g = new QButtonGroup(this);
g->hide();
g->insert(rb1);
g->insert(rb2);
g->insert(rb3);
QVBoxLayout * layout = new QVBoxLayout(this);
layout->addSpacing(30);
layout->addWidget(rb1);
layout->addSpacing(30);
layout->addWidget(rb2);
layout->addSpacing(30);
layout->addWidget(rb3);
layout->addSpacing(30);
show();
}
protected slots:
void entered()
{
for (QListIterator<MyRadio> it(buttonList); it.current(); ++it)
it.current()->highlight(true);
}
void left()
{
for (QListIterator<MyRadio> it(buttonList); it.current(); ++it)
it.current()->highlight(false);
}
private:
QList<MyRadio> buttonList;
};
int main(int argc, char ** argv)
{
QApplication * app = new QApplication(argc, argv);
MyWidget * w = new MyWidget;
app->setMainWidget(w);
return app->exec();
}
#include "radiotest.moc"
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic