本文整理汇总了C++中QUiLoader::load方法的典型用法代码示例。如果您正苦于以下问题:C++ QUiLoader::load方法的具体用法?C++ QUiLoader::load怎么用?C++ QUiLoader::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QUiLoader
的用法示例。
在下文中一共展示了QUiLoader::load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dataStream
QWidget *UiAPI::LoadFromFile(const QString &filePath, bool addToScene, QWidget *parent)
{
QWidget *widget = 0;
if (AssetAPI::ParseAssetRefType(filePath) != AssetAPI::AssetRefLocalPath)
{
AssetPtr asset = owner->Asset()->GetAsset(filePath);
if (!asset)
{
LogError(("LoadFromFile: Asset \"" + filePath + "\" is not loaded to the asset system. Call RequestAsset prior to use!").toStdString());
return 0;
}
QtUiAsset *uiAsset = dynamic_cast<QtUiAsset*>(asset.get());
if (!uiAsset)
{
LogError(("LoadFromFile: Asset \"" + filePath + "\" is not of type QtUiFile!").toStdString());
return 0;
}
if (!uiAsset->IsLoaded())
{
LogError(("LoadFromFile: Asset \"" + filePath + "\" data is not valid!").toStdString());
return 0;
}
// Get the asset data with the assetrefs replaced to point to the disk sources on the current local system.
QByteArray data = uiAsset->GetRefReplacedAssetData();
QUiLoader loader;
QDataStream dataStream(&data, QIODevice::ReadOnly);
widget = loader.load(dataStream.device(), parent);
}
else // The file is from absolute source location.
{
QFile file(filePath);
QUiLoader loader;
file.open(QFile::ReadOnly);
widget = loader.load(&file, parent);
}
if (!widget)
{
LogError(("LoadFromFile: Failed to load widget from file \"" + filePath + "\"!").toStdString());
return 0;
}
if (addToScene && widget)
AddWidgetToScene(widget);
return widget;
}
示例2: main
int main(int argc, char **argv)
{
Q_INIT_RESOURCE(table);
QApplication app(argc, argv);
QScriptEngine engine;
QFile scriptFile(":/table.js");
scriptFile.open(QIODevice::ReadOnly);
engine.evaluate(scriptFile.readAll());
scriptFile.close();
QUiLoader loader;
QFile uiFile(":/table.ui");
uiFile.open(QIODevice::ReadOnly);
QWidget *ui = loader.load(&uiFile);
uiFile.close();
QScriptValue func = engine.evaluate("Table");
QScriptValue scriptUi = engine.newQObject(ui);
QScriptValue table = func.construct(QScriptValueList() << scriptUi);
if(engine.hasUncaughtException()) {
QScriptValue value = engine.uncaughtException();
QString lineNumber = QString("\nLine Number:%1\n").arg(engine.uncaughtExceptionLineNumber());
QStringList btList = engine.uncaughtExceptionBacktrace();
QString trace;
for(short i=0; i<btList.size(); ++i)
trace += btList.at(i);
QMessageBox::information(NULL, QObject::tr("Exception"), value.toString() + lineNumber + trace );
}
ui->show();
return app.exec();
}
示例3: InitEditorWindow
void OgreScriptEditor::InitEditorWindow()
{
// Create widget from ui file
QUiLoader loader;
QFile file("./data/ui/ogrescripteditor.ui");
if (!file.exists())
{
OgreAssetEditorModule::LogError("Cannot find OGRE Script Editor .ui file.");
return;
}
mainWidget_ = loader.load(&file);
file.close();
layout_ = new QVBoxLayout;
layout_->addWidget(mainWidget_);
layout_->setContentsMargins(0, 0, 0, 0);
setLayout(layout_);
// Get controls
lineEditName_ = mainWidget_->findChild<QLineEdit *>("lineEditName");
buttonSaveAs_ = mainWidget_->findChild<QPushButton *>("buttonSaveAs");
buttonCancel_ = mainWidget_->findChild<QPushButton *>("buttonCancel");
// Connect signals
QObject::connect(buttonSaveAs_, SIGNAL(clicked()), this, SLOT(SaveAs()));
QObject::connect(buttonCancel_, SIGNAL(clicked(bool)), this, SLOT(Close()));
QObject::connect(lineEditName_, SIGNAL(textChanged(const QString &)), this, SLOT(ValidateScriptName(const QString &)));
}
示例4: LoadUI
POCO_END_MANIFEST
//API stuff here first
//for javascript to load a .ui file and get the widget in return, to assign connections
QScriptValue RexQtScript::LoadUI(QScriptContext *context, QScriptEngine *engine)
{
QWidget *widget;
QScriptValue qswidget;
boost::shared_ptr<QtUI::QtModule> qt_module = RexQtScript::staticframework->GetModuleManager()->GetModule<QtUI::QtModule>(Foundation::Module::MT_Gui).lock();
boost::shared_ptr<QtUI::UICanvas> canvas_;
//if ( qt_module.get() == 0)
// return NULL;
canvas_ = qt_module->CreateCanvas(QtUI::UICanvas::External).lock();
QUiLoader loader;
QFile file("../RexQtScriptModule/proto/dialog.ui");
widget = loader.load(&file);
canvas_->AddWidget(widget);
// Set canvas size.
canvas_->resize(widget->size());
canvas_->Show();
qswidget = engine->newQObject(widget);
return qswidget;
}
示例5: file
UploadProgressWindow::UploadProgressWindow(InventoryModule *owner, QWidget *parent) :
QWidget(parent), owner_(owner), mainWidget_(0), layout_(0), uploadCount_(0)
{
QUiLoader loader;
QFile file("./data/ui/uploadprogress.ui");
file.open(QFile::ReadOnly);
mainWidget_ = loader.load(&file, this);
file.close();
layout_ = new QVBoxLayout;
layout_->addWidget(mainWidget_);
setLayout(layout_);
progressBar_ = mainWidget_->findChild<QProgressBar *>("progressBar");
labelFileNumber_ = mainWidget_->findChild<QLabel *>("labelFileNumber");
// Add widget to UI via ui services module
boost::shared_ptr<UiServices::UiModule> ui_module =
owner_->GetFramework()->GetModuleManager()->GetModule<UiServices::UiModule>(Foundation::Module::MT_UiServices).lock();
if (!ui_module.get())
return;
proxyWidget_ = ui_module->GetInworldSceneController()->AddWidgetToScene(
this, UiServices::UiWidgetProperties("Upload Progress Window", UiServices::SceneWidget));
}
示例6: attachAllWidget
void MainWindow::attachAllWidget()
{
QString displayname;
QUiLoader loader;
//const int singletime = 1;
QFile file;
for(int i = 0; i < displayDocklist.size();i++)
{
displayname = QString("/usr/local/opi/ui/")+displayDocklist.at(i)+".ui";
//pattach = new AttachChannelAccess(displayname.toStdString().c_str(), i, singletime );
file.setFileName(displayname);
file.open(QFile::ReadOnly);
pwidget = loader.load(&file);
vecACHAcc.push_back(pwidget);
if (!pwidget)
{
QWidget *page = new QWidget();
QPushButton *pbut = new QPushButton(page);
pbut -> setGeometry(0,0,180,40);
char display[30];
sprintf(display,"%s: %d",displayname.toStdString().c_str(), i);
pbut -> setText(display);
stackedWidget->addWidget(page);
}
else
{
pwidget->setAutoFillBackground (true);
stackedWidget->addWidget(pwidget);
};
};
}
示例7: dataStream
QWidget *QtUiAsset::Instantiate(bool addToScene, QWidget *parent)
{
if (!IsLoaded())
{
LogError("QtUiAsset::Instantiate: Cannot instantiate an unloaded UI Asset \"" + Name().toStdString() + "\"!");
return 0;
}
// Get the asset data with the assetrefs replaced to point to the disk sources on the current local system.
QByteArray data = GetRefReplacedAssetData();
QUiLoader loader;
QDataStream dataStream(&data, QIODevice::ReadOnly);
QWidget *widget = loader.load(dataStream.device(), parent);
if (!widget)
{
LogError("QtUiAsset::Instantiate: Failed to instantiate widget from UI asset \"" + Name().toStdString() + "\"!");
return 0;
}
if (addToScene)
{
UiProxyWidget *proxy = assetAPI->GetFramework()->Ui()->AddWidgetToScene(widget);
if (!proxy)
LogError("QtUiAsset::Instantiate: Failed to add widget to main QGraphicsScene in UI asset \"" + Name().toStdString() + "\"!");
}
return widget;
}
示例8: InitEditorWindow
void UICanvasTestEdit::InitEditorWindow()
{
boost::shared_ptr<UiServices::UiModule> ui_module = framework_->GetModuleManager()->GetModule<UiServices::UiModule>(Foundation::Module::MT_UiServices).lock();
// If this occurs, we're most probably operating in headless mode.
if (ui_module.get() == 0)
return;
QUiLoader loader;
QFile file("./data/ui/uicanvastestedit.ui");
if (!file.exists())
{
QtModule::LogError("Cannot find UI canvas test editor .ui file.");
return;
}
editor_widget_ = loader.load(&file);
if (!editor_widget_)
return;
editor_widget_proxy_ = ui_module->GetSceneManager()->AddWidgetToScene(editor_widget_, UiServices::UiWidgetProperties(QPointF(60,60), editor_widget_->size(), Qt::Dialog, "3D GUI"));
// Connect signals
QPushButton *button = editor_widget_->findChild<QPushButton *>("but_bind");
if (button)
QObject::connect(button, SIGNAL(clicked()), this, SLOT(BindCanvas()));
button = editor_widget_->findChild<QPushButton *>("but_unbind");
if (button)
QObject::connect(button, SIGNAL(clicked()), this, SLOT(UnbindCanvas()));
QObject::connect(editor_widget_proxy_, SIGNAL(Visible(bool)), this, SLOT(Shown(bool)));
}
示例9: ui_file
Plugin::Plugin(const QVariantMap &metadata, Plugin::Type type)
: m_metadata(metadata), m_type(type), m_enabled(true)
{
if ( m_metadata.contains("ui") )
{
QStringList ui = m_metadata["ui"].toStringList();
if ( ui.isEmpty() )
ui << m_metadata["ui"].toString();
foreach(QString file_name, ui)
{
QFile ui_file(QDir(string_data("plugin_dir"))
.absoluteFilePath(file_name) );
if ( ui_file.open(QFile::ReadOnly|QFile::Text) )
{
QUiLoader loader;
QWidget *widget = loader.load(&ui_file);
if ( widget )
{
if ( widget->windowIcon().isNull() )
widget->setWindowIcon(icon());
//((QObject*)widget)->setParent(this);
widget->hide();
m_widgets << widget;
connect(widget,SIGNAL(destroyed(QObject*)),SLOT(dialog_destroyed(QObject*)));
}
}
}
示例10: uiFile
QWidget *ActionProxyWidget::OpenSimAvatarEditWidget(Data::OpenSimAvatar *data)
{
QWidget *os_edit_widget;
QUiLoader loader;
QFile uiFile("./data/ui/ether/avatar-edit-opensim.ui");
os_edit_widget = loader.load(&uiFile, 0);
uiFile.close();
QLineEdit *line_edit;
line_edit = os_edit_widget->findChild<QLineEdit*>("firstNameLineEdit");
line_edit->setText(data->firstName());
line_edit = os_edit_widget->findChild<QLineEdit*>("lastNameLineEdit");
line_edit->setText(data->lastName());
line_edit = os_edit_widget->findChild<QLineEdit*>("passwordLineEdit");
line_edit->setText(data->password());
QPixmap pic = CretatePicture(QSize(150,150), data->pixmapPath());
QLabel *pic_label = os_edit_widget->findChild<QLabel*>("pictureLabel");
pic_label->setPixmap(pic);
QPushButton *button = os_edit_widget->findChild<QPushButton*>("pushButtonSave");
connect(button, SIGNAL( clicked() ), SLOT( SaveInformation() ));
// Store data pointer and define types for save function
current_type_ = "avatar-opensim";
current_os_avatar_data_ = data;
return os_edit_widget;
}
示例11: ShowWindow
void KeyBindingsConfigWindow::ShowWindow()
{
QUiLoader loader;
QFile file("./data/ui/KeyBindingsConfig.ui");
file.open(QFile::ReadOnly);
QWidget *contents_widget_ = loader.load(&file, this);
assert(contents_widget_);
file.close();
if (!contents_widget_)
return;
QVBoxLayout *layout = new QVBoxLayout;
assert(layout);
layout->addWidget(contents_widget_);
layout->setContentsMargins(0,0,0,0);
setLayout(layout);
configList = findChild<QTreeWidget*>("configList");
QPushButton *apply = findChild<QPushButton*>("pushButtonApply");
connect(apply, SIGNAL(pressed()), this, SLOT(ApplyKeyConfig()));
QPushButton *ok = findChild<QPushButton*>("pushButtonOK");
connect(ok, SIGNAL(pressed()), this, SLOT(ButtonOK()));
QPushButton *cancel = findChild<QPushButton*>("pushButtonCancel");
connect(cancel, SIGNAL(pressed()), this, SLOT(ButtonCancel()));
connect(configList, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(ConfigListAdjustEditable(QTreeWidgetItem *, int)));
connect(configList, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), this, SLOT(ConfigListAdjustEditable(QTreeWidgetItem *, int)));
PopulateBindingsList();
setWindowTitle(tr("Actions"));
setAttribute(Qt::WA_DeleteOnClose);
}
示例12: showSingleton
void CAPopUp::showSingleton ()
{
#if 1
QString uifile = p_data->m_filename;
//qDebug("uifile-name:%s", uifile.toStdString().c_str());
if(uifile.isEmpty() == true || bshow == 0 ) return;
//qDebug("uifile-name-1:%s", uifile.toStdString().c_str());
if(p_data->m_singleton != 0) return;
QUiLoader loader;
QString filename = QString("/usr/local/opi/ui/") + uifile;
QFile file;
file.setFileName(filename);
file.open(QFile::ReadOnly);
QDialog *pDia = (QDialog*)loader.load(&file);
if(!pDia) return;
connect(pDia, SIGNAL(rejected()), this, SLOT(buttonCancel()));
QDialogButtonBox *pBBox = pDia->findChild<QDialogButtonBox *> ("buttonBox");
if(pBBox!=0)
{
connect(pBBox, SIGNAL(rejected()), this, SLOT(buttonCancel()));
}
pDia -> show();
p_data->m_singleton = 1;
#endif
}
示例13: loadControlUI
void EditorWindow::loadControlUI()
{
QModelIndex Select = ControllerTree->selectionModel()->selectedIndexes()[0];
QModelIndex SelectRoot = Controllers->getRootSelection(Select);
QString Key = Controllers->data(SelectRoot, Qt::DisplayRole).toString();
qDebug() << Key;
if (Key == currentControl)
return;
QFile controllerUIFile("./Controllers/" + Key + ".ui");
if (!controllerUIFile.exists())
{
QMessageBox::warning(this, tr("UI File"),
tr("Cannot found file %1:\n%2.")
.arg(controllerUIFile.fileName())
.arg(controllerUIFile.errorString()));
return;
}
if (!controllerUIFile.open(QFile::ReadOnly | QFile::Text))
{
QMessageBox::warning(this, tr("UI File"),
tr("Cannot read file %1:\n%2.")
.arg(controllerUIFile.fileName())
.arg(controllerUIFile.errorString()));
return;
}
QUiLoader UiLoader;
clearLayout(ControllerUI->layout());
ControllerUI->layout()->addWidget(UiLoader.load(&controllerUIFile, ControllerUI));
controllerUIFile.close();
}
示例14: file
//! [1]
CalculatorForm::CalculatorForm(QWidget *parent)
: QWidget(parent)
{
QUiLoader loader;
QFile file(":/forms/calculatorform.ui");
file.open(QFile::ReadOnly);
QWidget *formWidget = loader.load(&file, this);
file.close();
//! [1]
//! [2]
ui_inputSpinBox1 = qFindChild<QSpinBox*>(this, "inputSpinBox1");
ui_inputSpinBox2 = qFindChild<QSpinBox*>(this, "inputSpinBox2");
ui_outputWidget = qFindChild<QLabel*>(this, "outputWidget");
//! [2]
//! [3]
QMetaObject::connectSlotsByName(this);
//! [3]
//! [4]
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(formWidget);
setLayout(layout);
setWindowTitle(tr("Calculator Builder"));
}
示例15: file
UploadProgressWindow::UploadProgressWindow(InventoryModule *owner, QWidget *parent) :
QWidget(parent), owner_(owner), mainWidget_(0), layout_(0), uploadCount_(0)
{
QUiLoader loader;
QFile file("./data/ui/uploadprogress.ui");
file.open(QFile::ReadOnly);
mainWidget_ = loader.load(&file, this);
file.close();
layout_ = new QVBoxLayout;
layout_->addWidget(mainWidget_);
setLayout(layout_);
progressBar_ = mainWidget_->findChild<QProgressBar *>("progressBar");
labelFileNumber_ = mainWidget_->findChild<QLabel *>("labelFileNumber");
setWindowTitle(tr("Upload Progress Window"));
#ifndef UISERVICE_TEST
// Add widget to UI via ui services module
UiServices::UiModule *ui_module = owner_->GetFramework()->GetModule<UiServices::UiModule>();
if (ui_module)
proxyWidget_ = ui_module->GetInworldSceneController()->AddWidgetToScene(this);
#endif
}