本文整理汇总了C++中QLayout::addWidget方法的典型用法代码示例。如果您正苦于以下问题:C++ QLayout::addWidget方法的具体用法?C++ QLayout::addWidget怎么用?C++ QLayout::addWidget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLayout
的用法示例。
在下文中一共展示了QLayout::addWidget方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadPost
//.........这里部分代码省略.........
readAndClearButton->hide();
unsubscribeButton->hide();
copyLinkButton->show();
if (IS_GROUP_SUBSCRIBED(mGroupMeta.mSubscribeFlags) || IS_GROUP_ADMIN(mGroupMeta.mSubscribeFlags))
{
readButton->setVisible(true);
#if 0
uint32_t status = 0;
rsChannels->getMessageStatus(mChanId, mMsgId, status);
#endif
if (IS_MSG_UNREAD(post.mMeta.mMsgStatus) || IS_MSG_NEW(post.mMeta.mMsgStatus))
{
readButton->setChecked(true);
readButton->setIcon(QIcon(":/images/message-state-unread.png"));
}
else
{
readButton->setChecked(false);
readButton->setIcon(QIcon(":/images/message-state-read.png"));
}
bool newState;
QColor color;
if (!IS_MSG_UNREAD(post.mMeta.mMsgStatus))
{
//newLabel->setVisible(false);
newState = false;
color = COLOR_NORMAL;
}
else
{
//newLabel->setVisible(true);
newState = true;
color = COLOR_NEW;
}
/* unpolish widget to clear the stylesheet's palette cache */
frame->style()->unpolish(frame);
QPalette palette = frame->palette();
palette.setColor(frame->backgroundRole(), color);
frame->setPalette(palette);
frame->setProperty("new", newState);
Rshare::refreshStyleSheet(frame, false);
}
else
{
readButton->setVisible(false);
//newLabel->setVisible(false);
}
}
msgLabel->setText(RsHtml().formatText(NULL, QString::fromUtf8(post.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
msgFrame->setVisible(!post.mMsg.empty());
datetimelabel->setText(DateTime::formatLongDateTime(post.mMeta.mPublishTs));
filelabel->setText(QString("(%1 %2) %3").arg(post.mCount).arg(tr("Files")).arg(misc::friendlyUnit(post.mSize)));
if (mFileItems.empty() == false) {
std::list<SubFileItem *>::iterator it;
for(it = mFileItems.begin(); it != mFileItems.end(); it++)
{
delete(*it);
}
mFileItems.clear();
}
std::list<RsGxsFile>::const_iterator it;
for(it = post.mFiles.begin(); it != post.mFiles.end(); it++)
{
/* add file */
std::string path;
SubFileItem *fi = new SubFileItem(it->mHash, it->mName, path, it->mSize,
SFI_STATE_REMOTE | SFI_TYPE_CHANNEL, "");
mFileItems.push_back(fi);
/* check if the file is a media file */
if (!misc::isPreviewable(QFileInfo(QString::fromUtf8(it->mName.c_str())).suffix()))
fi->mediatype();
QLayout *layout = expandFrame->layout();
layout->addWidget(fi);
}
if(post.mThumbnail.mData != NULL)
{
QPixmap thumbnail;
thumbnail.loadFromData(post.mThumbnail.mData, post.mThumbnail.mSize, "PNG");
// Wiping data - as its been passed to thumbnail.
logoLabel->setPixmap(thumbnail);
}
m_inUpdateItemStatic = false;
}
示例2: SetOrUnsetButtonForActiveTool
void QmitkToolSelectionBox::SetOrUnsetButtonForActiveTool()
{
// we want to emit a signal in any case, whether we selected ourselves or somebody else changes "our" tool manager.
// --> emit before check on m_SelfCall
int id = m_ToolManager->GetActiveToolID();
// don't emit signal for shape model tools
bool emitSignal = true;
mitk::Tool *tool = m_ToolManager->GetActiveTool();
if (tool && std::string(tool->GetGroup()) == "organ_segmentation")
emitSignal = false;
if (emitSignal)
emit ToolSelected(id);
// delete old GUI (if any)
if (m_LastToolGUI && m_ToolGUIWidget)
{
if (m_ToolGUIWidget->layout())
{
m_ToolGUIWidget->layout()->removeWidget(m_LastToolGUI);
}
// m_LastToolGUI->reparent(nullptr, QPoint(0,0));
// TODO: reparent <-> setParent, Daniel fragen
m_LastToolGUI->setParent(0);
delete m_LastToolGUI; // will hopefully notify parent and layouts
m_LastToolGUI = nullptr;
QLayout *layout = m_ToolGUIWidget->layout();
if (layout)
{
layout->activate();
}
}
QToolButton *toolButton(nullptr);
// mitk::Tool* tool = m_ToolManager->GetActiveTool();
if (m_ButtonIDForToolID.find(id) != m_ButtonIDForToolID.end()) // if this tool is in our box
{
// toolButton = dynamic_cast<QToolButton*>( Q3ButtonGroup::find( m_ButtonIDForToolID[id] ) );
toolButton = dynamic_cast<QToolButton *>(m_ToolButtonGroup->buttons().at(m_ButtonIDForToolID[id]));
}
if (toolButton)
{
// mmueller
// uncheck all other buttons
QAbstractButton *tmpBtn = 0;
QList<QAbstractButton *>::iterator it;
for (int i = 0; i < m_ToolButtonGroup->buttons().size(); ++i)
{
tmpBtn = m_ToolButtonGroup->buttons().at(i);
if (tmpBtn != toolButton)
dynamic_cast<QToolButton *>(tmpBtn)->setChecked(false);
}
toolButton->setChecked(true);
if (m_ToolGUIWidget && tool)
{
// create and reparent new GUI (if any)
itk::Object::Pointer possibleGUI = tool->GetGUI("Qmitk", "GUI").GetPointer(); // prefix and postfix
QmitkToolGUI *gui = dynamic_cast<QmitkToolGUI *>(possibleGUI.GetPointer());
//!
m_LastToolGUI = gui;
if (gui)
{
gui->SetTool(tool);
// mmueller
// gui->reparent(m_ToolGUIWidget, gui->geometry().topLeft(), true );
gui->setParent(m_ToolGUIWidget);
gui->move(gui->geometry().topLeft());
gui->show();
QLayout *layout = m_ToolGUIWidget->layout();
if (!layout)
{
layout = new QVBoxLayout(m_ToolGUIWidget);
}
if (layout)
{
// mmueller
layout->addWidget(gui);
// layout->add( gui );
layout->activate();
}
}
}
}
else
{
// disable all buttons
QToolButton *selectedToolButton = dynamic_cast<QToolButton *>(m_ToolButtonGroup->checkedButton());
// QToolButton* selectedToolButton = dynamic_cast<QToolButton*>( Q3ButtonGroup::find( Q3ButtonGroup::selectedId() )
// );
if (selectedToolButton)
//.........这里部分代码省略.........
示例3: spIP
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui_(CONNECT_TO_SERVER)
{
//ui->setupUi(this);
//connect UI build
connectUI_ = new QWidget(this);
QLayout * connectLayout = new QHBoxLayout(connectUI_);
connectUI_->setLayout(connectLayout);
connectLayout->addWidget(new QLabel("Server",connectUI_));
QLineEdit *edit_ip = new QLineEdit(connectUI_);
edit_ip->setObjectName(QStringLiteral("edit_ip"));
edit_ip->setText( "218.56.11.182");
QSizePolicy spIP(QSizePolicy::Preferred, QSizePolicy::Fixed);
spIP.setHorizontalStretch(3);
edit_ip->setSizePolicy(spIP);
connectLayout->addWidget(edit_ip);
connectLayout->addWidget(new QLabel(":",connectUI_));
QLineEdit *edit_port = new QLineEdit(connectUI_);
edit_port->setObjectName(QStringLiteral("edit_port"));
edit_port->setText( "8888");
QSizePolicy spPort(QSizePolicy::Preferred, QSizePolicy::Fixed);
spPort.setHorizontalStretch(1);
edit_port->setSizePolicy(spPort);
connectLayout->addWidget(edit_port);
QPushButton *btn_Connect = new QPushButton(connectUI_);
btn_Connect->setObjectName(QStringLiteral("btn_Connect"));
btn_Connect->setText(QApplication::translate("MainWindow", "Connect", 0));
QObject::connect(btn_Connect,&QPushButton::clicked,this,&MainWindow::OnConnectServer);
connectLayout->addWidget(btn_Connect);
//peer list ui
peerListUI_ = new QTreeWidget(this);
peerListUI_->header()->setVisible(false);
QObject::connect(peerListUI_,&QTreeWidget::itemDoubleClicked,this,&MainWindow::OnItemDoubleClicked);
//peerListUI_->hide();
//stream ui
//streamUI_ = new StreamingUIWidget(this);
//streamUI_->setMinimumSize(640,480);
//streamUI_->hide();
QWidget *newCenter = new QWidget(this);
QVBoxLayout * centerLayout = new QVBoxLayout(newCenter);
centerLayout->addWidget(connectUI_);
centerLayout->addWidget(peerListUI_);
//centerLayout->addWidget(streamUI_);
this->setCentralWidget(newCenter);
QObject::connect(this,&MainWindow::signalUIThreadCallback,
this,&MainWindow::OnUIThreadCallback,
Qt::QueuedConnection);
}
示例4: setLayout
GTrans::GTrans() {
//lzt QTextcode modify for Utf8
QTextCodec::setCodecForTr(QTextCodec::codecForLocale());
QTextCodec::setCodecForCStrings( QTextCodec::codecForLocale());
//Layout
// QLayout *mainLayout = new QVBoxLayout;
QLayout *mainLayout = new QStackedLayout;
// The input section
// QLayout *top = new QHBoxLayout;
// QBoxLayout *tl = new QVBoxLayout;
// QLabel *inLabel = new QLabel(tr("Input:"));
// mainLayout->addWidget(inLabel); //lzt add
// fromLang = new QComboBox;
// tl->addWidget(inLabel);
// tl->addSpacing(10);
// tl->addWidget(fromLang);
// tl->addStretch();
// top->addItem(tl);
// inputTxt = new QTextEdit;
// top->addWidget(inputTxt);
// mainLayout->addWidget(inputTxt); //lzt add
// The output section
// QLayout *bottom = new QHBoxLayout;
// QBoxLayout *bl = new QVBoxLayout;
// QLabel *outLabel = new QLabel(tr("Output:"));
// toLang = new QComboBox;
// bl->addWidget(outLabel);
// bl->addSpacing(10);
// bl->addWidget(toLang);
// bl->addStretch();
// bottom->addItem(bl);
// mainLayout->addWidget(outLabel); //lzt add
outputTxt = new QTextEdit;
// outputTxt->setReadOnly(true);
// bottom->addWidget(outputTxt);
mainLayout->addWidget(outputTxt); //lzt add
// mainLayout->addItem(top);
// mainLayout->addItem(bottom);
// Translate button
// trans_b = new QPushButton(tr("Translate"));
// mainLayout->addWidget(trans_b);
setLayout(mainLayout);
setWindowTitle(tr("Translate"));
// trans_b->setDefault(true);
// connect(trans_b, SIGNAL(clicked()), this, SLOT(doTrans()));
//lzt clip
QClipboard *clipboard = QApplication::clipboard();
connect(clipboard, SIGNAL(selectionChanged()), this, SLOT(doTrans()));
//
// Setup foxus and tab order.
// inputTxt->setTabChangesFocus(true);
// inputTxt->setFocus(Qt::ActiveWindowFocusReason);
// outputTxt->setFocusProxy(trans_b);
}
示例5: load
void TemplateOptionsPage::load(const SourceFileTemplate& fileTemplate, TemplateRenderer* renderer)
{
d->entries.clear();
QLayout* layout = new QVBoxLayout();
QHash<QString, QList<SourceFileTemplate::ConfigOption> > options = fileTemplate.customOptions(renderer);
QHash<QString, QList<SourceFileTemplate::ConfigOption> >::const_iterator it;
for (it = options.constBegin(); it != options.constEnd(); ++it)
{
QGroupBox* box = new QGroupBox(this);
box->setTitle(it.key());
QFormLayout* formLayout = new QFormLayout;
d->entries << it.value();
foreach (const SourceFileTemplate::ConfigOption& entry, it.value())
{
QLabel* label = new QLabel(entry.label, box);
QWidget* control = nullptr;
const QString type = entry.type;
if (type == QLatin1String("String"))
{
control = new QLineEdit(entry.value.toString(), box);
}
else if (type == QLatin1String("Int"))
{
auto input = new QSpinBox(box);
input->setValue(entry.value.toInt());
if (!entry.minValue.isEmpty())
{
input->setMinimum(entry.minValue.toInt());
}
if (!entry.maxValue.isEmpty())
{
input->setMaximum(entry.maxValue.toInt());
}
control = input;
}
else if (type == QLatin1String("Bool"))
{
bool checked = (QString::compare(entry.value.toString(), QStringLiteral("true"), Qt::CaseInsensitive) == 0);
QCheckBox* checkBox = new QCheckBox(entry.label, box);
checkBox->setCheckState(checked ? Qt::Checked : Qt::Unchecked);
}
else
{
qCDebug(PLUGIN_FILETEMPLATES) << "Unrecognized option type" << entry.type;
}
if (control)
{
formLayout->addRow(label, control);
d->controls.insert(entry.name, control);
}
}
box->setLayout(formLayout);
layout->addWidget(box);
}
setLayout(layout);
}
示例6: ExampleList
FlatButtonExamples::FlatButtonExamples(QWidget *parent)
: ExampleList(parent)
{
QLayout *layout = widget()->layout();
{
FlatButton *flatButton = new FlatButton;
flatButton->setText("Press me!");
flatButton->setMinimumSize(200, 42);
flatButton->setRole(Material::Primary);
// flatButton->setDisabled(true);
ExampleView *view = new ExampleView;
view->setWidget(flatButton);
view->setBackgroundRole(QPalette::Base);
Frame *frame = new Frame;
frame->setCodeSnippet(
"FlatButton *flatButton = new FlatButton;\n"
"flatButton->setText(\"Press me!\");"
);
frame->setWidget(view);
layout->addWidget(frame);
}
{
FlatButton *flatButton = new FlatButton;
flatButton->setText("Press me!");
flatButton->setMinimumSize(200, 42);
flatButton->setRole(Material::Secondary);
// flatButton->setDisabled(true);
ExampleView *view = new ExampleView;
view->setWidget(flatButton);
view->setBackgroundRole(QPalette::Base);
Frame *frame = new Frame;
frame->setCodeSnippet(
"FlatButton *flatButton = new FlatButton;\n"
"flatButton->setText(\"Press me!\");"
);
frame->setWidget(view);
layout->addWidget(frame);
}
{
FlatButton *flatButton = new FlatButton;
flatButton->setText("Press me!");
flatButton->setMinimumSize(200, 42);
flatButton->setRole(Material::Secondary);
flatButton->setBackgroundColor(QColor(0, 0, 0, 80));
//flatButton->setTextColor(Style::instance().themeColor("primary1"));
// flatButton->setDisabled(true);
ExampleView *view = new ExampleView;
view->setWidget(flatButton);
view->setBackgroundRole(QPalette::Base);
Frame *frame = new Frame;
frame->setCodeSnippet(
"FlatButton *flatButton = new FlatButton;\n"
"flatButton->setText(\"Press me!\");"
);
frame->setWidget(view);
layout->addWidget(frame);
}
{
FlatButton *flatButton = new FlatButton;
flatButton->setText("Press me!");
flatButton->setMinimumSize(200, 42);
flatButton->setRole(Material::Primary);
flatButton->setBackgroundMode(Qt::OpaqueMode);
//flatButton->setPrimaryTextColor(Qt::white);
flatButton->setPeakOpacity(0.25);
ExampleView *view = new ExampleView;
view->setWidget(flatButton);
view->setBackgroundRole(QPalette::Base);
Frame *frame = new Frame;
frame->setCodeSnippet(
"FlatButton *flatButton = new FlatButton;\n"
"flatButton->setText(\"Press me!\");"
);
frame->setWidget(view);
layout->addWidget(frame);
}
{
FlatButton *flatButton = new FlatButton;
flatButton->setText("Press me!");
flatButton->setMinimumSize(200, 42);
flatButton->setRole(Material::Secondary);
flatButton->setBackgroundMode(Qt::OpaqueMode);
//.........这里部分代码省略.........
示例7: QStackedWidget
DatabaseWidget::DatabaseWidget(Database* db, QWidget* parent)
: QStackedWidget(parent)
, m_db(db)
, m_searchUi(new Ui::SearchWidget())
, m_searchWidget(new QWidget())
, m_newGroup(Q_NULLPTR)
, m_newEntry(Q_NULLPTR)
, m_newParent(Q_NULLPTR)
{
m_searchUi->setupUi(m_searchWidget);
m_searchTimer = new QTimer(this);
m_searchTimer->setSingleShot(true);
m_mainWidget = new QWidget(this);
QLayout* layout = new QHBoxLayout(m_mainWidget);
m_splitter = new QSplitter(m_mainWidget);
m_splitter->setChildrenCollapsible(false);
QWidget* rightHandSideWidget = new QWidget(m_splitter);
m_searchWidget->setParent(rightHandSideWidget);
m_groupView = new GroupView(db, m_splitter);
m_groupView->setObjectName("groupView");
m_groupView->setContextMenuPolicy(Qt::CustomContextMenu);
connect(m_groupView, SIGNAL(customContextMenuRequested(QPoint)),
SLOT(emitGroupContextMenuRequested(QPoint)));
m_entryView = new EntryView(rightHandSideWidget);
m_entryView->setObjectName("entryView");
m_entryView->setContextMenuPolicy(Qt::CustomContextMenu);
m_entryView->setGroup(db->rootGroup());
connect(m_entryView, SIGNAL(customContextMenuRequested(QPoint)),
SLOT(emitEntryContextMenuRequested(QPoint)));
QAction* closeAction = new QAction(m_searchWidget);
QIcon closeIcon = filePath()->icon("actions", "dialog-close");
closeAction->setIcon(closeIcon);
m_searchUi->closeSearchButton->setDefaultAction(closeAction);
m_searchUi->closeSearchButton->setShortcut(Qt::Key_Escape);
m_searchWidget->hide();
m_searchUi->caseSensitiveCheckBox->setVisible(false);
QVBoxLayout* vLayout = new QVBoxLayout(rightHandSideWidget);
vLayout->setMargin(0);
vLayout->addWidget(m_searchWidget);
vLayout->addWidget(m_entryView);
rightHandSideWidget->setLayout(vLayout);
setTabOrder(m_searchUi->searchRootRadioButton, m_entryView);
setTabOrder(m_entryView, m_groupView);
setTabOrder(m_groupView, m_searchWidget);
m_splitter->addWidget(m_groupView);
m_splitter->addWidget(rightHandSideWidget);
m_splitter->setStretchFactor(0, 30);
m_splitter->setStretchFactor(1, 70);
layout->addWidget(m_splitter);
m_mainWidget->setLayout(layout);
m_editEntryWidget = new EditEntryWidget();
m_editEntryWidget->setObjectName("editEntryWidget");
m_historyEditEntryWidget = new EditEntryWidget();
m_editGroupWidget = new EditGroupWidget();
m_editGroupWidget->setObjectName("editGroupWidget");
m_changeMasterKeyWidget = new ChangeMasterKeyWidget();
m_changeMasterKeyWidget->headlineLabel()->setText(tr("Change master key"));
QFont headlineLabelFont = m_changeMasterKeyWidget->headlineLabel()->font();
headlineLabelFont.setBold(true);
headlineLabelFont.setPointSize(headlineLabelFont.pointSize() + 2);
m_changeMasterKeyWidget->headlineLabel()->setFont(headlineLabelFont);
m_databaseSettingsWidget = new DatabaseSettingsWidget();
m_databaseSettingsWidget->setObjectName("databaseSettingsWidget");
m_databaseOpenWidget = new DatabaseOpenWidget();
m_databaseOpenWidget->setObjectName("databaseOpenWidget");
m_keepass1OpenWidget = new KeePass1OpenWidget();
m_keepass1OpenWidget->setObjectName("keepass1OpenWidget");
m_unlockDatabaseWidget = new UnlockDatabaseWidget();
m_unlockDatabaseWidget->setObjectName("unlockDatabaseWidget");
addWidget(m_mainWidget);
addWidget(m_editEntryWidget);
addWidget(m_editGroupWidget);
addWidget(m_changeMasterKeyWidget);
addWidget(m_databaseSettingsWidget);
addWidget(m_historyEditEntryWidget);
addWidget(m_databaseOpenWidget);
addWidget(m_keepass1OpenWidget);
addWidget(m_unlockDatabaseWidget);
connect(m_splitter, SIGNAL(splitterMoved(int,int)), SIGNAL(splitterSizesChanged()));
connect(m_entryView->header(), SIGNAL(sectionResized(int,int,int)), SIGNAL(entryColumnSizesChanged()));
connect(m_groupView, SIGNAL(groupChanged(Group*)), this, SLOT(clearLastGroup(Group*)));
connect(m_groupView, SIGNAL(groupChanged(Group*)), SIGNAL(groupChanged()));
connect(m_groupView, SIGNAL(groupChanged(Group*)), m_entryView, SLOT(setGroup(Group*)));
connect(m_entryView, SIGNAL(entryActivated(Entry*, EntryModel::ModelColumn)),
SLOT(entryActivationSignalReceived(Entry*, EntryModel::ModelColumn)));
connect(m_entryView, SIGNAL(entrySelectionChanged()), SIGNAL(entrySelectionChanged()));
//.........这里部分代码省略.........
示例8: QWidget
ClientGUI::ClientGUI(QWidget *parent)
: QWidget(parent)
{
/**********
* Initialize NULL pointer
**********/
client = NULL;
/**********
* Build base application window
**********/
setWindowTitle("GaoChat Client");
// Construct tabs
tabPt = new map<QString,Tab*>;
tabs = new CloseableTabWidget(tabPt);
tabs->setDocumentMode(true);
tabs->setTabPosition(QTabWidget::North);
tabs->setTabsClosable(true);
Tab *groupChat = new GroupTab(this);
groupChat->setDisabled(true); // Disable until connected to server
tabPt->insert(std::pair<QString,Tab*>(ROOTTAB,groupChat));
tabs->addTab(groupChat,"Group Chat");
QLayout *mainLayout = new QVBoxLayout;
mainLayout->setMargin(0);
mainLayout->setSpacing(0);
mainLayout->addWidget(tabs);
setLayout(mainLayout);
/**********
* Dialog box prompting for server,port and nickname
**********/
configPrompt = new QDialog;
configPrompt->setWindowTitle("Settings");
configPrompt->setFixedSize(configPrompt->sizeHint());
configPrompt->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
QLayout *serverSettings = new QVBoxLayout;
serverAddr = new QLineEdit;
serverAddr->setFixedWidth(125);
serverAddr->setText("127.0.0.1");
serverPort = new QSpinBox;
serverPort->setMinimum(1024);
serverPort->setMaximum(65535);
serverPort->setValue(S_PORT);
// Radio buttons for UDP/TCP
serverSettings->addWidget(new QLabel("Server:"));
serverSettings->addWidget(serverAddr);
serverSettings->addWidget(new QLabel("Port:"));
serverSettings->addWidget(serverPort);
serverSettings->setSpacing(1);
serverSettings->setMargin(0);
QLayout *userSettings = new QVBoxLayout;
nick = new QLineEdit;
nick->setText("sudowork");
userSettings->addWidget(new QLabel("Nickname:"));
userSettings->addWidget(nick);
QPushButton *conn = new QPushButton("Connect");
connect(conn,SIGNAL(clicked()),this,SLOT(serverConnect()));
QPushButton *quit = new QPushButton("Quit");
connect(quit,SIGNAL(clicked()),this,SLOT(quit()));
QVBoxLayout *configLayout = new QVBoxLayout;
configLayout->addLayout(serverSettings);
configLayout->addLayout(userSettings);
configLayout->addWidget(conn);
configLayout->addWidget(quit);
configPrompt->setLayout(configLayout);
configPrompt->exec();
}
示例9: PageChanged
void ResourceWizard::PageChanged(int PageId)
{
//qDebug()<<"start"<<"PageId"<<PageId<<"CurrentPageId"<<CurrentPageId;
if(CurrentPageId == 0)
{
MultiLanguageString str;
str.SetTranslation("en",ui->DescriptionEn->text());
str.SetTranslation("ru",ui->DescripnionRu->text());
ResourceWidget->SetVariableName(ui->Name->text());
ResourceWidget->SetDescription(str);
}else if(CurrentPageId == 1)
{
ResourceWidget->SetTypeId(Type);
}else if(CurrentPageId == 2)
{
if(Type == "FixedString")
{
QCheckBox * e = ResourceWidget->GetTemplateWidgetByType(false,Type)->findChild<QCheckBox *>("NotEmptyCheckBox");
if(e)
e->setChecked(ui->StringNotEmpty->isChecked());
QLineEdit * FixedStringValue = ResourceWidget->GetTemplateWidgetByType(true,Type)->findChild<QLineEdit *>("FixedStringValue");
if(FixedStringValue)
FixedStringValue->setText(ui->StringDefaultValue->text());
}
}else if(CurrentPageId == 10)
{
if(IsAdditionalTab)
{
IsAdditionalTab = false;
MultiLanguageString str;
str.SetTranslation("en",ui->TabEn->text());
str.SetTranslation("ru",ui->TabRu->text());
ResourceWidget->SetSectionName(str);
}
}else if(CurrentPageId == 9)
{
if(IsAdditionalIf)
{
IsAdditionalIf = false;
ResourceWidget->SetVisibilityConditionValue(ui->VisibilityValue->text());
ResourceWidget->SetVisibilityConditionVariable(ui->VisibilityName->text());
}
}else if(CurrentPageId == 8)
{
if(Type == "Select")
{
QComboBox * SelectTypeCombo = ResourceWidget->GetTemplateWidgetByType(false,Type)->findChild<QComboBox *>("SelectTypeCombo");
if(SelectTypeCombo)
SelectTypeCombo->setCurrentText(ui->SelectType->currentText());
QPlainTextEdit * SelectValuesEdit = ResourceWidget->GetTemplateWidgetByType(false,Type)->findChild<QPlainTextEdit *>("SelectValuesEdit");
if(SelectValuesEdit)
SelectValuesEdit->setPlainText(ui->SelectLines->toPlainText());
QWidget *child = ResourceWidget->GetTemplateWidgetByType(true,Type)->findChild<QWidget *>("SelectWidget");
QLayout * layout = child->layout();
/*MultiSelect * OldSelect = child->findChild<MultiSelect *>();
if(OldSelect)
OldSelect->deleteLater();
MultiSelect * Select = new MultiSelect(child);*/
MultiSelect * Select = child->findChild<MultiSelect *>();
QStringList list = ui->SelectLines->toPlainText().split(QRegExp("[\r\n]"),QString::SkipEmptyParts);
MultiSelect *multi = ui->SelectDefaultValueContainer->findChild<MultiSelect *>();
Select->Update(ui->SelectType->currentText(), list, multi->GetSelectedIndex());
layout->addWidget(Select);
}
}else if(CurrentPageId == 7)
{
if(Type == "RandomString")
{
QLineEdit * RandomStringValue = ResourceWidget->GetTemplateWidgetByType(true,Type)->findChild<QLineEdit *>("RandomStringValue");
if(RandomStringValue)
RandomStringValue->setText(ui->RandomStringValue->text());
}
}else if(CurrentPageId == 4)
{
if(Type == "FixedInteger")
{
QSpinBox * min = ResourceWidget->GetTemplateWidgetByType(false,Type)->findChild<QSpinBox *>("EditMinimum");
QSpinBox * max = ResourceWidget->GetTemplateWidgetByType(false,Type)->findChild<QSpinBox *>("EditMaximum");
if(min)
min->setValue(ui->MinValueNumber->value());
if(max)
max->setValue(ui->MaxValueNumber->value());
QSpinBox * FixedIntegerValue = ResourceWidget->GetTemplateWidgetByType(true,Type)->findChild<QSpinBox *>("FixedIntegerValue");
if(FixedIntegerValue)
FixedIntegerValue->setValue(ui->Number->value());
//.........这里部分代码省略.........
示例10: setup
void BookmarkWidget::setup(bool showButtons)
{
regExp.setPatternSyntax(QRegExp::FixedString);
regExp.setCaseSensitivity(Qt::CaseInsensitive);
QLayout *vlayout = new QVBoxLayout(this);
vlayout->setMargin(4);
QLabel *label = new QLabel(tr("Filter:"), this);
vlayout->addWidget(label);
searchField = new QLineEdit(this);
vlayout->addWidget(searchField);
connect(searchField, SIGNAL(textChanged(QString)), this,
SLOT(filterChanged()));
treeView = new TreeView(this);
vlayout->addWidget(treeView);
#ifdef Q_OS_MAC
# define SYSTEM "mac"
#else
# define SYSTEM "win"
#endif
if (showButtons) {
QLayout *hlayout = new QHBoxLayout();
vlayout->addItem(hlayout);
hlayout->addItem(new QSpacerItem(40, 20, QSizePolicy::Expanding));
addButton = new QToolButton(this);
addButton->setText(tr("Add"));
addButton->setIcon(QIcon(QLatin1String(":/assistant-icons/addtab.png")));
addButton->setAutoRaise(true);
addButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
hlayout->addWidget(addButton);
connect(addButton, SIGNAL(clicked()), this, SIGNAL(addBookmark()));
removeButton = new QToolButton(this);
removeButton->setText(tr("Remove"));
removeButton->setIcon(QIcon(QLatin1String(":/assistant-icons/closetab.png")));
removeButton->setAutoRaise(true);
removeButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
hlayout->addWidget(removeButton);
connect(removeButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
}
filterBookmarkModel = new QSortFilterProxyModel(this);
treeView->setModel(filterBookmarkModel);
treeView->setDragEnabled(true);
treeView->setAcceptDrops(true);
treeView->setAutoExpandDelay(1000);
treeView->setDropIndicatorShown(true);
treeView->header()->setVisible(false);
treeView->viewport()->installEventFilter(this);
treeView->setContextMenuPolicy(Qt::CustomContextMenu);
connect(treeView, SIGNAL(expanded(QModelIndex)), this,
SLOT(expand(QModelIndex)));
connect(treeView, SIGNAL(collapsed(QModelIndex)), this,
SLOT(expand(QModelIndex)));
connect(treeView, SIGNAL(activated(QModelIndex)), this,
SLOT(activated(QModelIndex)));
connect(treeView, SIGNAL(customContextMenuRequested(QPoint)),
this, SLOT(customContextMenuRequested(QPoint)));
filterBookmarkModel->setFilterKeyColumn(0);
filterBookmarkModel->setDynamicSortFilter(true);
filterBookmarkModel->setSourceModel(bookmarkManager->treeBookmarkModel());
expandItems();
}
示例11: KFileWidget
//.........这里部分代码省略.........
toolbar);
QObject::connect(refreshAction, SIGNAL(triggered(bool)),
this, SLOT(handleRefreshAction()));
QAction *searchAction = new QAction (*searchIcon, "Search",
toolbar);
QObject::connect(searchAction, SIGNAL(triggered(bool)),
this, SLOT(handleSearchAction()));
QAction *settingsAction = new QAction (*settingsIcon, "Settings",
toolbar);
QObject::connect(settingsAction, SIGNAL(triggered(bool)),
this, SLOT(handleSettingsAction()));
QAction *manualAction = new QAction (*manualIcon, "Manual",
toolbar);
QObject::connect(manualAction, SIGNAL(triggered(bool)),
this, SLOT(handleManualAction()));
QAction *aboutAction = new QAction (*aboutIcon, "About",
toolbar);
QObject::connect(aboutAction, SIGNAL(triggered(bool)),
this, SLOT(handleAboutAction()));
QAction *renameAction = new QAction (*renameIcon, "Rename",
toolbar);
QObject::connect(renameAction, SIGNAL(triggered(bool)),
this, SLOT(handleRenameAction()));
QAction *selectAllAction = new QAction (*selectAllIcon, "Select all",
toolbar);
QObject::connect(selectAllAction, SIGNAL(triggered(bool)),
this, SLOT(handleSelectAllAction()));
QAction *selectNoneAction = new QAction (*selectNoneIcon, "Select none",
toolbar);
QObject::connect(selectNoneAction, SIGNAL(triggered(bool)),
this, SLOT(handleSelectNoneAction()));
newMenu = new QMenu ();
QToolButton *newButton = new QToolButton();
newMenu->addAction (newBrowserAction);
newMenu->addAction (newDirAction);
newMenu->addAction (newFileAction);
newButton->setMenu (newMenu);
newButton->setIcon (*newBrowserIcon);
newButton->setPopupMode (QToolButton::InstantPopup);
newButton->setText ("New");
newButton->setToolButtonStyle (Qt::ToolButtonTextUnderIcon);
editMenu = new QMenu ();
QToolButton *editButton = new QToolButton();
editMenu->addAction (deleteAction);
editMenu->addAction (cutAction);
editMenu->addAction (copyAction);
editMenu->addAction (pasteAction);
editMenu->addAction (renameAction);
editMenu->addSeparator();
editMenu->addAction (selectAllAction);
editMenu->addAction (selectNoneAction);
editButton->setMenu (editMenu);
editButton->setIcon (*copyIcon);
editButton->setPopupMode (QToolButton::InstantPopup);
editButton->setText ("Edit");
editButton->setToolButtonStyle (Qt::ToolButtonTextUnderIcon);
helpMenu = new QMenu ();
QToolButton *helpButton = new QToolButton();
helpMenu->addAction (manualAction);
helpMenu->addAction (aboutAction);
helpButton->setMenu (helpMenu);
helpButton->setIcon (*helpIcon);
helpButton->setPopupMode (QToolButton::InstantPopup);
helpButton->setText ("Help");
helpButton->setToolButtonStyle (Qt::ToolButtonTextUnderIcon);
toolbar->addAction (exitAction);
toolbar->addAction (refreshAction);
toolbar->addAction (openAction);
toolbar->addAction (upAction);
toolbar->addAction (homeAction);
toolbar->addAction (viewAction);
toolbar->addAction (searchAction);
toolbar->addWidget(newButton);
toolbar->addWidget(editButton);
toolbar->addAction (settingsAction);
toolbar->addWidget (helpButton);
pathDisplay = new QLabel ();
pathDisplay->setObjectName ("pathDisplay");
pathDisplay->setTextFormat (Qt::PlainText);
layout->addWidget (toolbar);
layout->addWidget (pathDisplay);
layout->addWidget (list);
setLayout (layout);
pasteByNameOnly = false;
}
示例12: setObjectName
MeasurementWidget::MeasurementWidget(Form::FormItem *formItem, QWidget *parent) :
Form::IFormWidget(formItem,parent),
m_units(0),
m_value(0),
m_defaultUnitId(-1),
m_isWeight(false),
m_isLength(false)
{
setObjectName("MeasurementWidget");
bool uiBased = false;
QLayout *hb = 0;
const QString &layout = formItem->spec()->value(Form::FormItemSpec::Spec_UiInsertIntoLayout).toString();
const QString &widgets = formItem->spec()->value(Form::FormItemSpec::Spec_UiWidget).toString();
// Manage Qt UI files and pure FreeMedForms defined forms
if (widgets.isEmpty() && !layout.isEmpty()) {
// QtUi Loaded using layout
// Here the user wants to build the measurement widget from a
// Qt UI file inside a specific layout.
// We need here to insert the measurement widgets inside the layout
// This includes a label, one value (spin) and one unit (combo) editor
QLayout *lay = formItem->parentFormMain()->formWidget()->findChild<QLayout*>(layout);
if (lay) {
hb = lay;
} else {
LOG_ERROR("Using the QtUiLinkage, layout not found in the ui: " + formItem->uuid() + "; layout name: "+ layout);
// To avoid segfaulting create a fake combo
hb = new QHBoxLayout(this);
}
// Find Label
m_Label = findLabel(formItem);
// Add spin + combo to the layout
m_units = new QComboBox(this);
m_value = new QDoubleSpinBox(this);
hb->addWidget(m_value);
hb->addWidget(m_units);
uiBased= true;
} else if (!widgets.isEmpty() && layout.isEmpty()) {
// Qt Ui using widgets naming
// Here the user wants to build a measurement widget from a
// Qt UI file using specific & defined widgets.
// We need here to get the measurement widgets from the UI
// This includes a label, one value (spin) and one unit (combo) editor
// The FormItem widget string content must include two objectname
// coma separated. Eg: "widget1Value;widget2Units"
if (widgets.count(";") != 1) {
LOG_ERROR("Wrong widget naming. No ; found.");
} else {
QStringList w = widgets.split(";");
QDoubleSpinBox *value = formItem->parentFormMain()->formWidget()->findChild<QDoubleSpinBox*>(w.at(0));
if (value) {
m_value = value;
} else {
LOG_ERROR("Using the QtUiLinkage, value spinbox not found in the ui: " + formItem->uuid() + "; widget name: "+ w.at(0));
}
QComboBox *units = formItem->parentFormMain()->formWidget()->findChild<QComboBox*>(w.at(1));
if (units) {
m_units = units;
} else {
LOG_ERROR("Using the QtUiLinkage, units combobox not found in the ui: " + formItem->uuid() + "; widget name: "+ w.at(1));
}
uiBased = true;
}
// Find Label
m_Label = findLabel(formItem);
} else if (!widgets.isEmpty() && !layout.isEmpty()) {
// This is a form coding error
// Users can choose two Qt UI method: use widgets, insert in a layout
// Not both
LOG_ERROR(QString("Item %1 can not be constructed. "
"Please choose between QtUI widgets method or Qt UI layout insertion method. You can not use both")
.arg(formItem->spec()->uuid())
);
} else {
// Pure FreeMedForms form. User does not use any Qt UI file.
// We need here to create the measurement widgets and insert them inside the right layout
// Widgets include: a label, one value (spin) and one unit (combo) editor
hb = getBoxLayout(OnLeft, m_FormItem->spec()->label(), this);
hb->addWidget(m_Label);
hb->setMargin(0);
hb->setSpacing(0);
}
// Ensure that the widgets are available
// - layout
if (!hb && (!m_units || !m_value) && !uiBased) {
LOG_ERROR("No layout, creating a default one. Form item: " + formItem->uuid());
hb = new QHBoxLayout(this);
} else if (!hb && !uiBased) {
hb = getBoxLayout(OnLeft, m_FormItem->spec()->label(), this);
hb->addWidget(m_Label);
hb->setMargin(0);
hb->setSpacing(0);
}
// - value editor
if (!m_value) {
m_value = new QDoubleSpinBox(this);
m_value->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
hb->addWidget(m_value);
//.........这里部分代码省略.........
示例13: EditorToolWidget
/**
* Constructs a new PropertyDialog.
*/
PropertyDialog::PropertyDialog(NeuralNetworkEditor *owner)
: EditorToolWidget(owner), mInitialized(false), mCurrentProperties(0),
mPropertyList(0), mListScrollArea(0),
mSetButton(0), mChangeButton(0), mRemoveButton(0), mPropertySelectionField(0),
mValueEditField(0)
{
setObjectName("PropertyDialog");
QVBoxLayout *layout = new QVBoxLayout(this);
layout->setObjectName("MainLayout");
setLayout(layout);
QLayout *nameLayout = new QHBoxLayout();
layout->addLayout(nameLayout);
QLayout *listLayout = new QHBoxLayout();
listLayout->setObjectName("ListLayout");
layout->addLayout(listLayout);
QHBoxLayout *propertySelectLayout = new QHBoxLayout();
layout->addLayout(propertySelectLayout);
QHBoxLayout *valueEditLayout = new QHBoxLayout();
layout->addLayout(valueEditLayout);
QHBoxLayout *buttonLayout = new QHBoxLayout();
buttonLayout->setObjectName("ButtonLayout");
layout->addLayout(buttonLayout);
QHBoxLayout *autoSelectLayout = new QHBoxLayout();
autoSelectLayout->setObjectName("AutoSelectLayout");
layout->addLayout(autoSelectLayout);
QHBoxLayout *typeSelectionLayout = new QHBoxLayout();
layout->addLayout(typeSelectionLayout);
QHBoxLayout *typeSelectionLayoutLower = new QHBoxLayout();
layout->addLayout(typeSelectionLayoutLower);
mNameLabel = new QLabel("");
nameLayout->addWidget(mNameLabel);
mPropertyList = new QListWidget(this);
mListScrollArea = new QScrollArea(this);
mListScrollArea->setWidget(mPropertyList);
mListScrollArea->setWidgetResizable(true);
listLayout->addWidget(mListScrollArea);
mPropertySelectionField = new QComboBox(this);
mPropertySelectionField->setEditable(true);
addStandardPropertyTemplates();
propertySelectLayout->addWidget(mPropertySelectionField);
mValueEditField = new QLineEdit();
valueEditLayout->addWidget(mValueEditField);
mSetButton = new QPushButton("Set", this);
mSetButton->setContentsMargins(2, 2, 2, 2);
mSetButton->setMinimumWidth(15);
mChangeButton = new QPushButton("Change", this);
mChangeButton->setContentsMargins(2, 2, 2, 2);
mChangeButton->setMinimumWidth(15);
mRemoveButton = new QPushButton("Delete", this);
mRemoveButton->setContentsMargins(2, 2, 2, 2);
mRemoveButton->setMinimumWidth(15);
mApplyToAllIndividuals = new QCheckBox("All", this);
mApplyToAllIndividuals->setChecked(false);
mApplyToAllIndividuals->setToolTip("Apply changes to all individuals (Evolution only)");
mShowAllProperties = new QCheckBox("H", this);
mShowAllProperties->setChecked(false),
mShowAllProperties->setToolTip("Show also hidden properties");
buttonLayout->addWidget(mSetButton);
buttonLayout->addWidget(mChangeButton);
buttonLayout->addWidget(mRemoveButton);
buttonLayout->addWidget(mApplyToAllIndividuals);
buttonLayout->addWidget(mShowAllProperties);
mSelectMatchingElementsButton = new QPushButton("Select Matching");
mForceExactMatchForSelectionCheckBox = new QCheckBox("Exact");
mForceExactMatchForSelectionCheckBox->setChecked(false);
mShowNonMatchingElementsCheckBox = new QCheckBox("Negate");
mShowNonMatchingElementsCheckBox->setChecked(false);
autoSelectLayout->addWidget(mSelectMatchingElementsButton);
autoSelectLayout->addWidget(mForceExactMatchForSelectionCheckBox);
autoSelectLayout->addWidget(mShowNonMatchingElementsCheckBox);
mConsiderNeurons = new QCheckBox("N");
mConsiderSynapses = new QCheckBox("S");
mConsiderGroups = new QCheckBox("G");
mConsiderModules = new QCheckBox("M");
mHelpButton = new QPushButton("Help");
mHelpButton->setContentsMargins(2, 2, 2, 2);
mHelpButton->setMinimumWidth(15);
//.........这里部分代码省略.........
示例14: request
/**
* Request the video to avoid the conflicts
**/
WId VideoWidget::request( int *pi_x, int *pi_y,
unsigned int *pi_width, unsigned int *pi_height,
bool b_keep_size )
{
msg_Dbg( p_intf, "Video was requested %i, %i", *pi_x, *pi_y );
if( reparentable != NULL )
{
msg_Dbg( p_intf, "embedded video already in use" );
return NULL;
}
if( b_keep_size )
{
*pi_width = size().width();
*pi_height = size().height();
}
/* The Qt4 UI needs a fixed a widget ("this"), so that the parent layout is
* not messed up when we the video is reparented. Hence, we create an extra
* reparentable widget, that will be within the VideoWidget in windowed
* mode, and within the root window (NULL parent) in full-screen mode.
*/
reparentable = new ReparentableWidget( this );
QLayout *innerLayout = new QHBoxLayout( reparentable );
innerLayout->setContentsMargins( 0, 0, 0, 0 );
/* The owner of the video window needs a stable handle (WinId). Reparenting
* in Qt4-X11 changes the WinId of the widget, so we need to create another
* dummy widget that stays within the reparentable widget. */
QWidget *stable = new QWidget();
QPalette plt = palette();
plt.setColor( QPalette::Window, Qt::black );
stable->setPalette( plt );
stable->setAutoFillBackground(true);
/* Indicates that the widget wants to draw directly onto the screen.
Widgets with this attribute set do not participate in composition
management */
stable->setAttribute( Qt::WA_PaintOnScreen, true );
innerLayout->addWidget( stable );
layout->addWidget( reparentable );
#ifdef Q_WS_X11
/* HACK: Only one X11 client can subscribe to mouse button press events.
* VLC currently handles those in the video display.
* Force Qt4 to unsubscribe from mouse press and release events. */
Display *dpy = QX11Info::display();
Window w = stable->winId();
XWindowAttributes attr;
XGetWindowAttributes( dpy, w, &attr );
attr.your_event_mask &= ~(ButtonPressMask|ButtonReleaseMask);
XSelectInput( dpy, w, attr.your_event_mask );
#endif
videoSync();
#ifndef NDEBUG
msg_Dbg( p_intf, "embedded video ready (handle %p)",
(void *)stable->winId() );
#endif
return stable->winId();
}