本文整理汇总了C++中QLabel::text方法的典型用法代码示例。如果您正苦于以下问题:C++ QLabel::text方法的具体用法?C++ QLabel::text怎么用?C++ QLabel::text使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLabel
的用法示例。
在下文中一共展示了QLabel::text方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setPanelDisplayingPath
void ContentUI::setPanelDisplayingPath(const QString &name, EPath path, EPanels panel)
{
QLabel* label = getPanelLabel(panel);
QString pathDividerSign(QDir::toNativeSeparators("/"));
int labelTextlength = label->text().length();
int discStrLength = getDiscLength(panel);
switch(path)
{
case EForward:
{
QString divider((labelTextlength == discStrLength) ? "" : pathDividerSign);
label->setText(label->text() += (divider + name));
}
break;
case EBackward:
{
int pos = label->text().lastIndexOf(pathDividerSign);
int removeCount = labelTextlength - (pos + 1) + 1;
if(pos == (discStrLength - 1)) ++pos;
label->setText(label->text().remove(pos, removeCount));
}
break;
}
}
示例2: slotButtonViewClicked
void Search::slotButtonViewClicked()
{
QLabel title;
QLabel year;
QLabel director;
QLabel genre;
QLabel time;
QLabel link;
QLabel description;
QString film = model->index(view->currentIndex().row(), 0).data().toString();
QSqlQuery query("SELECT * "
"FROM films "
"WHERE title = '" + film + "'");
while(query.next())
{
title.setText(query.value(0).toString());
year.setText(query.value(1).toString());
director.setText(query.value(2).toString());
genre.setText(query.value(3).toString());
time.setText(query.value(4).toString());
description.setText(query.value(5).toString());
link.setText(query.value(6).toString());
}
QPixmap map(link.text());
info->setWindowTitle(tr("Информация о фильме"));
info->setText(tr("Название: ") + title.text() + tr("\n\nГод: ") + year.text() + tr("\n\nРежиссер: ") + director.text() + tr("\n\nЖанр: ") + genre.text() + tr("\n\nОписание: ") + description.text());
info->setIconPixmap(map);
info->exec();
}
示例3: onItemDeleted
void
ItemSelectorWidget::onDeletePressed()
{
if ( m_items.count() > 0 )
{
QLabel* lastLabel = m_items.takeLast();
int cursorPos = lastLabel->text().length();
ui.searchBox->setText( lastLabel->text() + ui.searchBox->text() );
ui.searchBox->setCursorPosition( cursorPos );
onItemDeleted( lastLabel );
}
}
示例4: dealPressList
void ListWidget::dealPressList()
{
QLabel *label = (QLabel *)this->sender();
if(NULL == label)
return;
if (0 != label->text().size())
{
emit this->channelNumSignal(QString(label->text().at(0)).toInt());
this->hide();
}
}
示例5: eventFilter
bool eventFilter(QObject *obj, QEvent *event) {
if ( event->type() == QEvent::Paint ) {
QLabel *l = static_cast<QLabel*>(obj);
QPainter painter(l);
int sep = 20;//l->height()*40/100;
QLinearGradient grad(0,0,0,sep);
grad.setColorAt(0,midBg);
grad.setColorAt(0.25,midLightBg);
grad.setColorAt(1,midLightBg);
painter.fillRect(0,0,l->width(),sep,grad);
grad = QLinearGradient(0,sep,0,40);//l->height());
grad.setColorAt(0,midLightBg);
grad.setColorAt(0.25,midBg);
grad.setColorAt(1,midBg);
painter.fillRect(0,sep,l->width(),l->height()-sep,grad);
painter.setPen(borderBg);
painter.drawLine(0,0,l->width(),0);
/*
painter.setPen(Qt::black);
painter.drawLine(0,0,0,l->height());
painter.drawLine(0,0,l->width(),0);
*/
if ( !l->text().isEmpty() ) {
grad = QLinearGradient(0,0,l->width(),0);
grad.setColorAt(0, QColor(255,255,255,0));
grad.setColorAt(0.25, QColor(255,255,255,128));
grad.setColorAt(0.5, QColor(255,255,255,192));
grad.setColorAt(0.75, QColor(255,255,255,128));
grad.setColorAt(1, QColor(255,255,255,0));
painter.fillRect(0,l->height()-1,l->width(),1,grad);
}
const QPixmap *pm = l->pixmap();
if ( pm != NULL ) {
int xofs = (l->width() - pm->width()) / 2;
int yofs = (l->height() - pm->height()) / 2;
painter.drawPixmap(xofs,yofs, *pm);
}
painter.setPen(Qt::white);
painter.drawText(l->rect().adjusted(20,0,0,0), Qt::AlignLeft | Qt::AlignVCenter, l->text());
return true;
}
return QObject::eventFilter(obj, event);
}
示例6: addCopy
void Progression::addCopy(QString src, QString){
QLabel * label = new QLabel(src, this);
label->setObjectName(src);
label->setMaximumSize(780, 30);
label->setGeometry(label->x(), label->y(), 780, label->height());
QProgressBar * prog = new QProgressBar(this);
prog->setObjectName(src);
prog->setMaximum(QFile(src).size());
vbl->addWidget(label);
vbl->addWidget(prog);
ProgressBars[label->text()] = prog;
qDebug() << label->text();
this->adjustSize();
}
示例7: updateTankDeaths
void FormGame::updateTankDeaths(ITank *killer)
{
ITank* tank = (ITank*)sender();
int index = _tanks.indexOf(tank);
if(index > -1)
{
int index_of_player = _match_players.value(index);
QLabel* label = findChild<QLabel*>(QString("_l_deaths_%1").arg(index_of_player));
label->setText(QString::number(label->text().toInt() + 1));
}
int killer_index = _tanks.indexOf(killer);
if(killer_index > -1)
{
int index_of_player = _match_players.value(killer_index);
QLabel* label = findChild<QLabel*>(QString("_l_kills_%1").arg(index_of_player));
label->setText(QString::number(label->text().toInt() + 1));
}
if(tank == _tank)
{
updateTankView();
}
PlayerData pd1 = _players_data.at(_tanks.indexOf(killer));
PlayerData pd2 = _players_data.at(_tanks.indexOf(tank));
if(killer->isEnemy() != tank->isEnemy())
{
KillsDeaths kills = _results.value(pd1).value(pd2);
kills._kills += 1;
QMap<PlayerData , KillsDeaths> kills_value;
kills_value.insert(pd2, kills);
_results.insert(pd1, kills_value);
KillsDeaths deaths = _results.value(pd2).value(pd1);
deaths._deaths += 1;
QMap<PlayerData , KillsDeaths> deaths_value;
deaths_value.insert(pd1, deaths);
_results.insert(pd2, deaths_value);
}
QString pd1_team = pd1._team == 1?"g":"r";
QString pd2_team = pd2._team == 1?"g":"r";
QString log("<span class='%1'>%2</span><span> ha aniquilado a </span><span class='%3'>%4</span>");
addLog(_text_style_template.arg(log.arg(pd1_team).arg(pd1._nick).arg(pd2_team).arg(pd2._nick)));
}
示例8: applyQListToLayout
void QVListLayout::applyQListToLayout(const QStringList &list)
{
bool toggle = true;
QLabel *bLabel;
QFont labelFont;
labelFont.setBold(true);
foreach(const QString &item, list)
{
if(!item.isEmpty())
{
bLabel = new QLabel(item);
bLabel->setWordWrap(true);
if(bLabel->text() != QLatin1String("--"))
{
if(toggle)
{
toggle = false;
bLabel->setFont(labelFont);
} else {
bLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
bLabel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
bLabel->setAlignment(Qt::AlignTop);
toggle = true;
}
} else {
bLabel->setText(QLatin1String(""));
}
addWidget(bLabel);
}
}
}
示例9: mousePressEvent
void DragDropArea::mousePressEvent(QMouseEvent *event)
{
QLabel *child = static_cast<QLabel*>(childAt(event->pos()));
if (!child)
return;
// Only drag children with dynamic property: "drag"
if (!child->property("drag").toBool())
return;
QPoint hotSpot = event->pos() - child->pos();
QMimeData *mimeData = new QMimeData;
mimeData->setText(child->text());
mimeData->setData("application/x-hotspot",
QByteArray::number(hotSpot.x())
+ " " + QByteArray::number(hotSpot.y()));
QPixmap pixmap(child->size());
child->render(&pixmap);
QDrag *drag = new QDrag(this);
drag->setMimeData(mimeData);
drag->setPixmap(pixmap);
drag->setHotSpot(hotSpot);
drag->exec();
}
示例10: egx_label_get_text_
int egx_label_get_text_(egx_wnd_t hwnd, char *text, int length)
{
QLabel *label = (QLabel*)(hwnd);
QString qText = label->text();
strncpy(text,qText.toLocal8Bit().data(),length - 1);
return 0;
}
示例11: perform
void ChangeLabelAction::perform( GuiElement *e )
{
kDebug() ;
editor()->beginEdit();
QString newLabel;
bool ok;
QString currentLabel;
QLabel *labelWidget = dynamic_cast<QLabel *>( e->labelWidget() );
if( labelWidget )
currentLabel = labelWidget->text();
newLabel = KInputDialog::getText( i18n("Enter the new label"), i18n("Label for %1:", e->ref().toString()),
currentLabel, &ok );
if( ok ) {
kDebug() <<"New Label:" << newLabel;
Hint h;
h.setRef( e->id() );
h.setValue( Hint::Label, newLabel );
emit hintGenerated( h );
}
editor()->finishEdit();
}
示例12: Handle
void ItemHandlerTreeView::Handle (const QDomElement& item, QWidget *pwidget)
{
QGridLayout *lay = qobject_cast<QGridLayout*> (pwidget->layout ());
QTreeView *tree = new QTreeView (XSD_);
tree->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding);
QString prop = item.attribute ("property");
tree->setObjectName (prop);
tree->setHeaderHidden (item.attribute ("hideHeader") == "true");
Factory_->RegisterDatasourceSetter (prop,
[this] (const QString& str, QAbstractItemModel *m, Util::XmlSettingsDialog*)
{ SetDataSource (str, m); });
Propname2TreeView_ [prop] = tree;
QLabel *label = new QLabel (XSD_->GetLabel (item));
label->setWordWrap (false);
tree->setProperty ("ItemHandler", QVariant::fromValue<QObject*> (this));
tree->setProperty ("SearchTerms", label->text ());
int row = lay->rowCount ();
lay->addWidget (label, row, 0, Qt::AlignLeft);
lay->addWidget (tree, row + 1, 0, 1, -1);
}
示例13: Handle
void ItemHandlerPath::Handle (const QDomElement& item,
QWidget *pwidget)
{
QGridLayout *lay = qobject_cast<QGridLayout*> (pwidget->layout ());
QLabel *label = new QLabel (XSD_->GetLabel (item));
label->setWordWrap (false);
FilePicker::Type type = FilePicker::Type::ExistingDirectory;
if (item.attribute ("pickerType") == "openFileName")
type = FilePicker::Type::OpenFileName;
else if (item.attribute ("pickerType") == "saveFileName")
type = FilePicker::Type::SaveFileName;
FilePicker *picker = new FilePicker (type, XSD_);
const QVariant& value = XSD_->GetValue (item);
picker->SetText (value.toString ());
picker->setObjectName (item.attribute ("property"));
if (item.attribute ("onCancel") == "clear")
picker->SetClearOnCancel (true);
if (item.hasAttribute ("filter"))
picker->SetFilter (item.attribute ("filter"));
connect (picker,
SIGNAL (textChanged (const QString&)),
this,
SLOT (updatePreferences ()));
picker->setProperty ("ItemHandler", QVariant::fromValue<QObject*> (this));
picker->setProperty ("SearchTerms", label->text ());
int row = lay->rowCount ();
lay->addWidget (label, row, 0);
lay->addWidget (picker, row, 1);
}
示例14: Handle
void ItemHandlerLineEdit::Handle (const QDomElement& item,
QWidget *pwidget)
{
QGridLayout *lay = qobject_cast<QGridLayout*> (pwidget->layout ());
QLabel *label = new QLabel (XSD_->GetLabel (item));
label->setWordWrap (false);
const QVariant& value = XSD_->GetValue (item);
QLineEdit *edit = new QLineEdit (value.toString ());
XSD_->SetTooltip (edit, item);
edit->setObjectName (item.attribute ("property"));
edit->setMinimumWidth (QApplication::fontMetrics ()
.width ("thisismaybeadefaultsetting"));
if (item.hasAttribute ("password"))
edit->setEchoMode (QLineEdit::Password);
if (item.hasAttribute ("inputMask"))
edit->setInputMask (item.attribute ("inputMask"));
connect (edit,
SIGNAL (textChanged (const QString&)),
this,
SLOT (updatePreferences ()));
edit->setProperty ("ItemHandler", QVariant::fromValue<QObject*> (this));
edit->setProperty ("SearchTerms", label->text ());
int row = lay->rowCount ();
lay->addWidget (label, row, 0, Qt::AlignRight);
lay->addWidget (edit, row, 1);
}
示例15: GWEN_Widget_GetText
const char *getCharProperty(GWEN_DIALOG_PROPERTY prop,
int index,
const char *defaultValue) {
QLabel *qw;
QString str;
qw=(QLabel*) GWEN_Widget_GetImplData(_widget, QT4_DIALOG_WIDGET_REAL);
assert(qw);
switch(prop) {
case GWEN_DialogProperty_Title:
str=qw->text();
if (str.isEmpty())
return defaultValue;
else {
GWEN_Widget_SetText(_widget, QT4_DIALOG_STRING_TITLE, str.toUtf8());
return GWEN_Widget_GetText(_widget, QT4_DIALOG_STRING_TITLE);
}
break;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(_widget)));
return defaultValue;
};