当前位置: 首页>>代码示例>>C++>>正文


C++ QLabel::text方法代码示例

本文整理汇总了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;
    }
}
开发者ID:jalcine,项目名称:google-drive-qt,代码行数:27,代码来源:contentui.cpp

示例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();
}
开发者ID:theWaR13,项目名称:Film-Database,代码行数:33,代码来源:search.cpp

示例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 );
    }
}
开发者ID:Erkan-Yilmaz,项目名称:lastfm-desktop,代码行数:12,代码来源:ItemSelectorWidget.cpp

示例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();
    }
}
开发者ID:andrinux1992,项目名称:sunplusedu_pro,代码行数:13,代码来源:listwidget.cpp

示例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);
		}
开发者ID:aemanov,项目名称:seiscomp3,代码行数:51,代码来源:gui.cpp

示例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();
}
开发者ID:ThomasAy,项目名称:Duplicateur,代码行数:14,代码来源:Progression.cpp

示例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)));
}
开发者ID:patadejaguar,项目名称:GuerraDeTanques,代码行数:48,代码来源:formgame.cpp

示例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);
    }
  }  
}
开发者ID:KDE,项目名称:kinfocenter,代码行数:34,代码来源:qvlistlayout.cpp

示例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();
}
开发者ID:arielmr,项目名称:SofiaTrigo,代码行数:27,代码来源:dragdroparea.cpp

示例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;
}
开发者ID:edgarliu,项目名称:easygx,代码行数:7,代码来源:easygx_control_.cpp

示例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();
}
开发者ID:zhao07,项目名称:kode,代码行数:26,代码来源:changelabelaction.cpp

示例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);
	}
开发者ID:Kalarel,项目名称:leechcraft,代码行数:27,代码来源:itemhandlertreeview.cpp

示例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);
	}
开发者ID:zhao07,项目名称:leechcraft,代码行数:34,代码来源:itemhandlerpath.cpp

示例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);
	}
开发者ID:Kalarel,项目名称:leechcraft,代码行数:30,代码来源:itemhandlerlineedit.cpp

示例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;
  };
开发者ID:Zauberstuhl,项目名称:gwenhywfar,代码行数:29,代码来源:w_label.cpp


注:本文中的QLabel::text方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。