本文整理汇总了C++中LineEdit类的典型用法代码示例。如果您正苦于以下问题:C++ LineEdit类的具体用法?C++ LineEdit怎么用?C++ LineEdit使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LineEdit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dialog
QString DVGui::getText(const QString &title, const QString &labelText,
const QString &text, bool *ok)
{
Dialog dialog(0, true);
dialog.setWindowTitle(title);
dialog.setWindowFlags(Qt::WindowStaysOnTopHint |
Qt::WindowTitleHint |
Qt::CustomizeWindowHint);
QVBoxLayout *layout = new QVBoxLayout(&dialog);
dialog.addLayout(layout);
QLabel *label = new QLabel(labelText, &dialog);
layout->addWidget(label);
LineEdit *nameFld = new LineEdit(text, &dialog);
layout->addWidget(nameFld);
QPushButton *okBtn = new QPushButton(dialog.tr("OK"), &dialog);
okBtn->setDefault(true);
QPushButton *cancelBtn = new QPushButton(dialog.tr("Cancel"), &dialog);
QObject::connect(okBtn, SIGNAL(clicked()), &dialog, SLOT(accept()));
QObject::connect(cancelBtn, SIGNAL(clicked()), &dialog, SLOT(reject()));
dialog.addButtonBarWidget(okBtn, cancelBtn);
int ret = dialog.exec();
if (ok)
*ok = (ret == QDialog::Accepted);
return nameFld->text();
}
示例2: NewProjectDialog
NewProjectDialog() {
VBoxContainer *vb = memnew( VBoxContainer );
add_child(vb);
set_child_rect(vb);
Label* l = memnew(Label);
l->set_text("Project Path:");
vb->add_child(l);
pp=l;
project_path = memnew( LineEdit );
MarginContainer *mc = memnew( MarginContainer );
vb->add_child(mc);
HBoxContainer *pphb = memnew( HBoxContainer );
mc->add_child(pphb);
pphb->add_child(project_path);
project_path->set_h_size_flags(SIZE_EXPAND_FILL);
Button* browse = memnew( Button );
pphb->add_child(browse);
browse->set_text("Browse");
browse->connect("pressed", this,"_browse_path");
l = memnew(Label);
l->set_text("Project Name:");
l->set_pos(Point2(5,50));
vb->add_child(l);
pn=l;
project_name = memnew( LineEdit );
mc = memnew( MarginContainer );
vb->add_child(mc);
mc->add_child(project_name);
project_name->set_text("New Game Project");
l = memnew(Label);
l->set_text("That's a BINGO!");
vb->add_child(l);
error=l;
l->add_color_override("font_color",Color(1,0.4,0.3,0.8));
l->set_align(Label::ALIGN_CENTER);
get_ok()->set_text("Create");
DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
project_path->set_text(d->get_current_dir());
memdelete(d);
fdialog = memnew( FileDialog );
add_child(fdialog);
fdialog->set_access(FileDialog::ACCESS_FILESYSTEM);
project_name->connect("text_changed", this,"_text_changed");
project_path->connect("text_changed", this,"_path_text_changed");
fdialog->connect("dir_selected", this,"_path_selected");
fdialog->connect("file_selected", this,"_file_selected");
set_hide_on_ok(false);
import_mode=false;
}
示例3: EditorMeshImportDialog
EditorMeshImportDialog(EditorMeshImportPlugin *p_plugin) {
plugin=p_plugin;
set_title(TTR("Single Mesh Import"));
set_hide_on_ok(false);
VBoxContainer *vbc = memnew( VBoxContainer );
add_child(vbc);
//set_child_rect(vbc);
HBoxContainer *hbc = memnew( HBoxContainer );
vbc->add_margin_child(TTR("Source Mesh(es):"),hbc);
import_path = memnew( LineEdit );
import_path->set_h_size_flags(SIZE_EXPAND_FILL);
hbc->add_child(import_path);
Button * import_choose = memnew( Button );
import_choose->set_text(" .. ");
hbc->add_child(import_choose);
import_choose->connect("pressed", this,"_browse");
hbc = memnew( HBoxContainer );
vbc->add_margin_child(TTR("Target Path:"),hbc);
save_path = memnew( LineEdit );
save_path->set_h_size_flags(SIZE_EXPAND_FILL);
hbc->add_child(save_path);
Button * save_choose = memnew( Button );
save_choose->set_text(" .. ");
hbc->add_child(save_choose);
save_choose->connect("pressed", this,"_browse_target");
file_select = memnew( EditorFileDialog );
file_select->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
file_select->set_mode(EditorFileDialog::MODE_OPEN_FILES);
file_select->add_filter("*.obj ; Wavefront OBJ");
add_child(file_select);
file_select->connect("files_selected", this,"_choose_files");
save_select = memnew( EditorDirDialog );
add_child(save_select);
save_select->connect("dir_selected", this,"_choose_save_dir");
get_ok()->connect("pressed", this,"_import");
get_ok()->set_text(TTR("Import"));
error_dialog = memnew( AcceptDialog );
add_child(error_dialog);
options = memnew( _EditorMeshImportOptions );
option_editor = memnew( PropertyEditor );
option_editor->hide_top_label();
vbc->add_margin_child(TTR("Options:"),option_editor,true);
}
示例4: CheckBox
void HelloGUI::InitControls()
{
// Create a CheckBox
CheckBox* checkBox = new CheckBox(context_);
checkBox->SetName("CheckBox");
// Create a Button
Button* button = new Button(context_);
button->SetName("Button");
button->SetMinHeight(24);
// Create a LineEdit
LineEdit* lineEdit = new LineEdit(context_);
lineEdit->SetName("LineEdit");
lineEdit->SetMinHeight(24);
// Add controls to Window
window_->AddChild(checkBox);
window_->AddChild(button);
window_->AddChild(lineEdit);
// Apply previously set default style
checkBox->SetStyleAuto();
button->SetStyleAuto();
lineEdit->SetStyleAuto();
}
示例5: switch
//------------------------------------------------------------------------------
void ConditionValueDelegate::setModelData(QWidget* editor,
QAbstractItemModel* model, const QModelIndex& index) const
{
switch (field(index))
{
case AssignmentRule::Date:
{
QDateEdit* dateEditor = static_cast<QDateEdit*>(editor);
QDate date = dateEditor->date();
model->setData(index, date.toString(Qt::ISODate), Qt::EditRole);
}
break;
case AssignmentRule::Amount:
{
MoneyEdit* moneyEditor = static_cast<MoneyEdit*>(editor);
Money amount = moneyEditor->value();
QString newVal = QString("%1,%2")
.arg(amount.amount()).arg(amount.currency().code());
model->setData(index, newVal, Qt::EditRole);
}
break;
default:
{
LineEdit* stringEditor = static_cast<LineEdit*>(editor);
model->setData(index, stringEditor->text(), Qt::EditRole);
}
}
}
示例6: SetText
bool LineEdit::OnDragDropFinish(UIElement* source)
{
if (source && editable_)
{
// If the UI element in question has a drag-and-drop content string defined, use it instead of element text
if (source->GetVars().Contains(VAR_DRAGDROPCONTENT))
{
SetText(source->GetVar(VAR_DRAGDROPCONTENT).GetString());
return true;
}
StringHash sourceType = source->GetType();
if (sourceType == LineEdit::GetTypeStatic())
{
LineEdit* sourceLineEdit = static_cast<LineEdit*>(source);
SetText(sourceLineEdit->GetText());
return true;
}
else if (sourceType == Text::GetTypeStatic())
{
Text* sourceText = static_cast<Text*>(source);
SetText(sourceText->GetText());
return true;
}
}
return false;
}
示例7: QVBoxLayout
/*
This function is defined here instead of PyGrxUI.cpp so that the message translations can be edited with one file
*/
std::string GrxUIMenuView::waitInputMessage(const std::string& message)
{
Dialog dialog;
dialog.setWindowTitle(_("Wait input message"));
QVBoxLayout* vbox = new QVBoxLayout();
dialog.setLayout(vbox);
vbox->addWidget(new QLabel(message.c_str()));
LineEdit* lineEdit = new LineEdit();
connect(lineEdit, SIGNAL(returnPressed()), &dialog, SLOT(accept()));
vbox->addWidget(lineEdit);
PushButton* okButton = new PushButton(_("&OK"));
okButton->setDefault(true);
connect(okButton, SIGNAL(clicked()), &dialog, SLOT(accept()));
vbox->addWidget(okButton);
vbox->addStretch();
dialog.show();
MenuButtonBlock block(instance()->impl);
QEventLoop eventLoop;
connect(&dialog, SIGNAL(finished(int)), &eventLoop, SLOT(quit()));
eventLoop.exec();
return lineEdit->string();
}
示例8: main
int main()
{
LineEdit edit;
while (1)
{
string s = edit.getData();
cout << s << endl;
}
}
示例9: create
void create() {
setTitle("Test Application");
setGeometry(Geometry(128, 128, 640, 480 ));
layout.append(bProcess);
layout.append(lvOutput);
layout.append(baseN);
layout.append(baseR);
unsigned bn = integer(baseN.text()), br = integer(baseR.text());
if (br>=0 && br<=bn) {
lstring hdr;
for (unsigned i = 0; i < br; ++i) {
hdr.append((string){i>0?",":"","B",i+1});
}
lvOutput.setHeaderText(hdr);
}
bProcess.setText("Draw!");
bProcess.onActivate = [&]() {
lvOutput.reset();
};
//Hook it all up
append(layout);
onClose = [&layout] {
// layout.setSkipGeomUpdates(true); //Example of skipping pointless update calculations.
OS::quit();
};
setVisible();
}
示例10: popup_import
void popup_import(const String& p_path) {
popup_centered(Size2(400,400));
if (p_path!="") {
Ref<ResourceImportMetadata> rimd = ResourceLoader::load_import_metadata(p_path);
ERR_FAIL_COND(!rimd.is_valid());
save_path->set_text(p_path.get_base_dir());
List<String> opts;
rimd->get_options(&opts);
for(List<String>::Element *E=opts.front();E;E=E->next()) {
options->_set(E->get(),rimd->get_option(E->get()));
}
String src = "";
for(int i=0;i<rimd->get_source_count();i++) {
if (i>0)
src+=",";
src+=EditorImportPlugin::expand_source_path(rimd->get_source_path(i));
}
import_path->set_text(src);
}
}
示例11: _browse_target
void EditorSceneImportDialog::_browse_target() {
if (save_path->get_text()!="")
save_select->set_current_path(save_path->get_text());
save_select->popup_centered_ratio();
}
示例12: _choose_file
void EditorSceneImportDialog::_choose_file(const String& p_path) {
#if 0
StringName sn = EditorImportDB::get_singleton()->find_source_path(p_path);
if (sn!=StringName()) {
EditorImportDB::ImportScene isc;
if (EditorImportDB::get_singleton()->get_scene(sn,isc)==OK) {
save_path->set_text(String(sn).get_base_dir());
texture_options->set_flags( isc.image_flags );
texture_options->set_quality( isc.image_quality );
texture_options->set_format( isc.image_format );
animation_options->set_flags( isc.anim_flags );
script_path->set_text( isc.import_script );
uint32_t f = isc.flags;
for(int i=0;i<scene_flags.size();i++) {
scene_flags[i]->set_checked(0,f&(1<<i));
}
}
} else {
#endif
save_path->set_text("");
//save_path->set_text(p_path.get_file().basename()+".scn");
#if 0
}
#endif
import_path->set_text(p_path);
}
示例13: popup_import
void EditorSceneImportDialog::popup_import(const String &p_from) {
popup_centered(Size2(700,500));
if (p_from!="") {
Ref<ResourceImportMetadata> rimd = ResourceLoader::load_import_metadata(p_from);
if (rimd.is_null())
return;
int flags = rimd->get_option("flags");
for(int i=0;i<scene_flags.size();i++) {
int md = scene_flags[i]->get_metadata(0);
scene_flags[i]->set_checked(0,flags&md);
}
texture_options->set_flags(rimd->get_option("texture_flags"));
texture_options->set_format(EditorTextureImportPlugin::ImageFormat(int(rimd->get_option("texture_format"))));
texture_options->set_quality(rimd->get_option("texture_quality"));
animation_options->set_flags(rimd->get_option("animation_flags"));
script_path->set_text(rimd->get_option("post_import_script"));
save_path->set_text(p_from.get_base_dir());
import_path->set_text(EditorImportPlugin::expand_source_path(rimd->get_source_path(0)));
}
}
示例14: _test_path
bool _test_path() {
error->set_text("");
get_ok()->set_disabled(true);
DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
if (project_path->get_text() != "" && d->change_dir(project_path->get_text())!=OK) {
error->set_text(TTR("Invalid project path, the path must exist!"));
memdelete(d);
return false;
}
if (mode!=MODE_IMPORT) {
if (d->file_exists("engine.cfg")) {
error->set_text(TTR("Invalid project path, engine.cfg must not exist."));
memdelete(d);
return false;
}
} else {
if (project_path->get_text() != "" && !d->file_exists("engine.cfg")) {
error->set_text(TTR("Invalid project path, engine.cfg must exist."));
memdelete(d);
return false;
}
}
memdelete(d);
get_ok()->set_disabled(false);
return true;
}
示例15: _test_path
bool _test_path() {
error->set_text("");
get_ok()->set_disabled(true);
DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
if (project_path->get_text() != "" && d->change_dir(project_path->get_text())!=OK) {
error->set_text("Invalid Path for Project, Path Must Exist!");
memdelete(d);
return false;
}
if (!import_mode) {
if (d->file_exists("engine.cfg")) {
error->set_text("Invalid Project Path (engine.cfg must not exist).");
memdelete(d);
return false;
}
} else {
if (project_path->get_text() != "" && !d->file_exists("engine.cfg")) {
error->set_text("Invalid Project Path (engine.cfg must exist).");
memdelete(d);
return false;
}
}
memdelete(d);
get_ok()->set_disabled(false);
return true;
}