Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F94259058
valuedit.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Dec 5, 05:26
Size
1 KB
Mime Type
text/x-c
Expires
Sat, Dec 7, 05:26 (2 d)
Engine
blob
Format
Raw Data
Handle
22771513
Attached To
rSYMKIT symkit
valuedit.cpp
View Options
#include "valuedit.h"
#include <QLineEdit>
#include <QLabel>
#include <QHBoxLayout>
Valuedit::Valuedit(const QString& name,
double init,
QWidget *parent)
: QWidget(parent)
{
this->name = new QLabel(name, this);
edit = new QLineEdit(this);
edit->setText(QString::number(init));
this->name->setBuddy(edit);
layout = new QHBoxLayout;
layout->addWidget(this->name);
layout->addWidget(edit);
setLayout(layout);
connect(edit, SIGNAL(returnPressed()), this, SLOT(returnHandler()));
}
Valuedit::~Valuedit()
{
delete name;
delete edit;
delete layout;
}
void Valuedit::returnHandler()
{
// remove focus
edit->clearFocus();
emit valueChanged(getValue());
}
QString Valuedit::getName() const
{
return name->text();
}
void Valuedit::setValue(double value, bool force)
{
if (force || !isFocused())
edit->setText(QString::number(value, 'g', 4));
}
double Valuedit::getValue() const
{
return edit->text().toDouble();
}
bool Valuedit::isFocused() const
{
return edit->hasFocus();
}
Event Timeline
Log In to Comment