本文整理汇总了C++中KLineEdit::setSizePolicy方法的典型用法代码示例。如果您正苦于以下问题:C++ KLineEdit::setSizePolicy方法的具体用法?C++ KLineEdit::setSizePolicy怎么用?C++ KLineEdit::setSizePolicy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KLineEdit
的用法示例。
在下文中一共展示了KLineEdit::setSizePolicy方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupUI
void setupUI() {
p->setObjectName(QStringLiteral("FieldLineEdit"));
hLayout = new QHBoxLayout(p);
hLayout->setMargin(0);
hLayout->setSpacing(2);
m_pushButtonType = new QPushButton(p);
appendWidget(m_pushButtonType);
hLayout->setStretchFactor(m_pushButtonType, 0);
m_pushButtonType->setObjectName(QStringLiteral("FieldLineEditButton"));
if (isMultiLine) {
m_multiLineEditText = new KTextEdit(p);
appendWidget(m_multiLineEditText);
connect(m_multiLineEditText, &KTextEdit::textChanged, p, &MenuLineEdit::slotTextChanged);
m_multiLineEditText->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
p->setFocusProxy(m_multiLineEditText);
m_multiLineEditText->setAcceptRichText(false);
} else {
m_singleLineEditText = new KLineEdit(p);
appendWidget(m_singleLineEditText);
hLayout->setStretchFactor(m_singleLineEditText, 100);
m_singleLineEditText->setClearButtonEnabled(true);
m_singleLineEditText->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
m_singleLineEditText->setCompletionMode(KCompletion::CompletionPopup);
m_singleLineEditText->completionObject()->setIgnoreCase(true);
p->setFocusProxy(m_singleLineEditText);
connect(m_singleLineEditText, &KLineEdit::textEdited, p, &MenuLineEdit::textChanged);
}
p->setFocusPolicy(Qt::StrongFocus); // FIXME improve focus handling
p->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
}
示例2: KDialogBase
DialogCreateTag::DialogCreateTag(QWidget *parent, TagTreeNode* parentNode, const char *name)
: KDialogBase(parent, name, true, "", KDialogBase::Ok|KDialogBase::Cancel, KDialogBase::Ok, false )
, m_parentNode(parentNode) {
if (parentNode) {
this->setCaption(i18n("Create tag"));
} else {
this->setCaption(i18n("Create toplevel tag"));
}
QWidget* mainPanel = new QWidget(this, "mainPanel");
setMainWidget(mainPanel);
QVBoxLayout* mainPanelLayout = new QVBoxLayout(mainPanel, 0, 5, "mainPanelLayout");
mainPanelLayout->setAutoAdd(true);
// parent
if (parentNode) {
// newTagGroup
QGroupBox* parentTagGroup = new QGroupBox(i18n("Parent tag"), mainPanel, "parentTagGroup");
QGridLayout* parentTagGroupLayout = new QGridLayout(parentTagGroup, 4, 4, 20, 5, "parentTagGroupLayout");
parentTagGroupLayout->setRowSpacing(0, 10);
// type
QLabel* typeLabel = new QLabel(i18n("Type"), parentTagGroup, "typeLabel");
parentTagGroupLayout->addWidget(typeLabel, 1, 0);
KComboBox* typeComboBox = new KComboBox(false, parentTagGroup, "typeComboBox");
typeComboBox->insertItem(parentNode->tagNode()->typeName());
typeComboBox->setEnabled(false);
parentTagGroupLayout->addMultiCellWidget(typeComboBox, 1, 1, 1, 2);
// name
QLabel* nameLabel = new QLabel(i18n("Name"), parentTagGroup, "nameLabel");
parentTagGroupLayout->addWidget(nameLabel, 2, 0);
KLineEdit* nameLineEdit = new KLineEdit(parentTagGroup, "nameLineEdit");
nameLineEdit->setText(*parentNode->tagNode()->text());
nameLineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
nameLineEdit->setReadOnly(true);
parentTagGroupLayout->addMultiCellWidget(nameLineEdit, 2, 2, 1, 2);
// icon
QLabel* iconLabel = new QLabel(i18n("Icon"), parentTagGroup, "iconLabel");
parentTagGroupLayout->addWidget(iconLabel, 3, 0);
KLineEdit* iconLineEdit = new KLineEdit(parentTagGroup, "iconLineEdit");
iconLineEdit->setText(*parentNode->tagNode()->iconName());
iconLineEdit->setMinimumWidth(300);
iconLineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
iconLineEdit->setReadOnly(true);
parentTagGroupLayout->addWidget(iconLineEdit, 3, 1);
QPushButton* iconButton = new QPushButton(i18n("Icon"), parentTagGroup, "iconButton");
QIconSet iconSet = KGlobal::iconLoader()->loadIconSet(iconLineEdit->text(), KIcon::Small, Configuration::getInstance()->tagtreeIconSize(), true);
iconButton->setIconSet(iconSet);
iconButton->setText(QString::null);
iconButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
iconButton->setEnabled(true);
parentTagGroupLayout->addWidget(iconButton, 3, 2);
}
// newTagGroup
QGroupBox* newTagGroup = new QGroupBox(i18n("New tag"), mainPanel, "newTagGroup");
QGridLayout* newTagGroupLayout = new QGridLayout(newTagGroup, 4, 4, 20, 5, "newTagGroupLayout");
newTagGroupLayout->setRowSpacing(0, 10);
// type
QLabel* typeLabel = new QLabel(i18n("Type"), newTagGroup, "typeLabel");
newTagGroupLayout->addWidget(typeLabel, 1, 0);
m_typeComboBox = new KComboBox(false, newTagGroup, "typeComboBox");
m_typeComboBoxEntries = new QValueList<int>;
if (!parentNode) {
m_typeComboBox->insertItem(TagNode::tagNodeTypeName(TagNode::TYPE_TITLE));
m_typeComboBoxEntries->append(TagNode::tagNodeTypeId(TagNode::TYPE_TITLE));
}
m_typeComboBox->insertItem(TagNode::tagNodeTypeName(TagNode::TYPE_BOOLEAN));
m_typeComboBoxEntries->append(TagNode::tagNodeTypeId(TagNode::TYPE_BOOLEAN));
newTagGroupLayout->addMultiCellWidget(m_typeComboBox, 1, 1, 1, 2);
// name
QLabel* nameLabel = new QLabel(i18n("Name"), newTagGroup, "nameLabel");
newTagGroupLayout->addWidget(nameLabel, 2, 0);
m_nameLineEdit = new KLineEdit(newTagGroup, "nameLineEdit");
m_nameLineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
QObject::connect(m_nameLineEdit, SIGNAL(textChanged(const QString&)), this, SLOT(slotNameChanged(const QString&)));
newTagGroupLayout->addMultiCellWidget(m_nameLineEdit, 2, 2, 1, 2);
// icon
QLabel* iconLabel = new QLabel(i18n("Icon"), newTagGroup, "iconLabel");
newTagGroupLayout->addWidget(iconLabel, 3, 0);
m_iconLineEdit = new KLineEdit(newTagGroup, "iconLineEdit");
m_iconLineEdit->setMinimumWidth(300);
m_iconLineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
QObject::connect(m_iconLineEdit, SIGNAL(textChanged(const QString&)), this, SLOT(slotIconTextChanged(const QString&)));
newTagGroupLayout->addWidget(m_iconLineEdit, 3, 1);
//.........这里部分代码省略.........
示例3: addJourneySearchWidgets
void TitleWidget::addJourneySearchWidgets()
{
// Add recent journeys button
Plasma::ToolButton *recentJourneysButton = new Plasma::ToolButton;
recentJourneysButton->setIcon( KIcon("document-open-recent") );
recentJourneysButton->setToolTip( i18nc("@info:tooltip", "Use a favorite/recent journey search") );
recentJourneysButton->nativeWidget()->setPopupMode( QToolButton::InstantPopup );
// This is needed, to have the popup menu drawn above other widgets
recentJourneysButton->setZValue( 9999 );
connect( recentJourneysButton, SIGNAL(clicked()), this, SLOT(slotJourneysIconClicked()) );
// Add button to start the journey search
Plasma::ToolButton *journeySearchButton = new Plasma::ToolButton;
journeySearchButton->setIcon( KIcon("edit-find") );
journeySearchButton->setToolTip( i18nc("@info:tooltip", "Find journeys") );
journeySearchButton->setEnabled( false );
connect( journeySearchButton, SIGNAL(clicked()), this, SLOT(slotJourneySearchInputFinished()) );
// Add journey search query input field
Plasma::LineEdit *journeySearchLineEdit = new Plasma::LineEdit;
journeySearchLineEdit->setNativeWidget( new JourneySearchLineEdit );
journeySearchLineEdit->setToolTip(
i18nc("@info:tooltip This should match the localized keywords.",
"<para>Type a <emphasis strong='1'>target stop</emphasis> or "
"<emphasis strong='1'>journey request</emphasis>.</para>"
"<para><emphasis strong='1'>Samples:</emphasis><list>"
"<item><emphasis>To target in 15 mins</emphasis></item>"
"<item><emphasis>From origin arriving tomorrow at 18:00</emphasis></item>"
"<item><emphasis>Target at 6:00 2010-03-07</emphasis></item>"
"</list></para>") );
journeySearchLineEdit->installEventFilter( this ); // Handle up/down keys (selecting stop suggestions)
journeySearchLineEdit->setClearButtonShown( true );
journeySearchLineEdit->nativeWidget()->setCompletionMode( KGlobalSettings::CompletionAuto );
journeySearchLineEdit->nativeWidget()->setCompletionModeDisabled(
KGlobalSettings::CompletionMan );
journeySearchLineEdit->nativeWidget()->setCompletionModeDisabled(
KGlobalSettings::CompletionPopup );
journeySearchLineEdit->nativeWidget()->setCompletionModeDisabled(
KGlobalSettings::CompletionPopupAuto );
journeySearchLineEdit->nativeWidget()->setCompletionModeDisabled(
KGlobalSettings::CompletionShell );
journeySearchLineEdit->setEnabled( true );
KLineEdit *journeySearch = journeySearchLineEdit->nativeWidget();
journeySearch->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
journeySearch->setClickMessage( i18nc("@info/plain", "Target stop name or journey request") );
KCompletion *completion = journeySearch->completionObject( false );
completion->setIgnoreCase( true );
journeySearchLineEdit->setFont( m_settings->sizedFont() );
connect( journeySearchLineEdit, SIGNAL(returnPressed()),
this, SLOT(slotJourneySearchInputFinished()) );
connect( journeySearchLineEdit, SIGNAL(textEdited(QString)),
this, SIGNAL(journeySearchInputEdited(QString)) );
connect( journeySearchLineEdit, SIGNAL(textChanged(QString)),
this, SLOT(slotJourneySearchInputChanged(QString)) );
// Add widgets
addWidget( journeySearchLineEdit, WidgetJourneySearchLine );
addWidget( recentJourneysButton, WidgetFillJourneySearchLineButton );
addWidget( journeySearchButton, WidgetStartJourneySearchButton );
}
示例4: setupGUI
void setupGUI()
{
QBoxLayout *layout = new QVBoxLayout(p);
tabWidget = new QTabWidget(p);
layout->addWidget(tabWidget);
QWidget *container = new QWidget(tabWidget);
tabWidget->addTab(container, QIcon::fromTheme(QStringLiteral("preferences-web-browser-identification")), i18n("Library"));
connect(tabWidget, &QTabWidget::currentChanged, p, &ZoteroBrowser::tabChanged);
QBoxLayout *containerLayout = new QVBoxLayout(container);
/// Personal or Group Library
QGridLayout *gridLayout = new QGridLayout();
containerLayout->addLayout(gridLayout);
gridLayout->setMargin(0);
gridLayout->setColumnMinimumWidth(0, 16); // TODO determine size of a radio button
radioPersonalLibrary = new QRadioButton(i18n("Personal library"), container);
gridLayout->addWidget(radioPersonalLibrary, 0, 0, 1, 2);
radioGroupLibrary = new QRadioButton(i18n("Group library"), container);
gridLayout->addWidget(radioGroupLibrary, 1, 0, 1, 2);
comboBoxGroupList = new KComboBox(false, container);
gridLayout->addWidget(comboBoxGroupList, 2, 1, 1, 1);
QSizePolicy sizePolicy = comboBoxGroupList->sizePolicy();
sizePolicy.setHorizontalPolicy(QSizePolicy::MinimumExpanding);
comboBoxGroupList->setSizePolicy(sizePolicy);
radioPersonalLibrary->setChecked(true);
comboBoxGroupList->setEnabled(false);
comboBoxGroupList->addItem(i18n("No groups available"));
connect(radioGroupLibrary, &QRadioButton::toggled, p, &ZoteroBrowser::radioButtonsToggled);
connect(radioPersonalLibrary, &QRadioButton::toggled, p, &ZoteroBrowser::radioButtonsToggled);
connect(comboBoxGroupList, static_cast<void (KComboBox::*)(int)>(&KComboBox::currentIndexChanged), p, &ZoteroBrowser::groupListChanged);
containerLayout->addStretch(10);
/// Credentials
QFormLayout *containerForm = new QFormLayout();
containerLayout->addLayout(containerForm, 1);
containerForm->setMargin(0);
lineEditNumericUserId = new KLineEdit(container);
lineEditNumericUserId->setSizePolicy(sizePolicy);
lineEditNumericUserId->setReadOnly(true);
containerForm->addRow(i18n("Numeric user id:"), lineEditNumericUserId);
connect(lineEditNumericUserId, &KLineEdit::textChanged, p, &ZoteroBrowser::invalidateGroupList);
lineEditApiKey = new KLineEdit(container);
lineEditApiKey->setSizePolicy(sizePolicy);
lineEditApiKey->setReadOnly(true);
containerForm->addRow(i18n("API key:"), lineEditApiKey);
connect(lineEditApiKey, &KLineEdit::textChanged, p, &ZoteroBrowser::invalidateGroupList);
QBoxLayout *containerButtonLayout = new QHBoxLayout();
containerLayout->addLayout(containerButtonLayout, 0);
containerButtonLayout->setMargin(0);
QPushButton *buttonGetOAuthCredentials = new QPushButton(QIcon::fromTheme(QStringLiteral("preferences-web-browser-identification")), i18n("Get New Credentials"), container);
containerButtonLayout->addWidget(buttonGetOAuthCredentials, 0);
connect(buttonGetOAuthCredentials, &QPushButton::clicked, p, &ZoteroBrowser::getOAuthCredentials);
containerButtonLayout->addStretch(1);
/// Collection browser
collectionBrowser = new QTreeView(tabWidget);
tabWidget->addTab(collectionBrowser, QIcon::fromTheme(QStringLiteral("folder-yellow")), i18n("Collections"));
collectionBrowser->setHeaderHidden(true);
collectionBrowser->setExpandsOnDoubleClick(false);
connect(collectionBrowser, &QTreeView::doubleClicked, p, &ZoteroBrowser::collectionDoubleClicked);
/// Tag browser
tagBrowser = new QListView(tabWidget);
tabWidget->addTab(tagBrowser, QIcon::fromTheme(QStringLiteral("mail-tagged")), i18n("Tags"));
connect(tagBrowser, &QListView::doubleClicked, p, &ZoteroBrowser::tagDoubleClicked);
}