本文整理汇总了C++中QListWidgetItem::setText方法的典型用法代码示例。如果您正苦于以下问题:C++ QListWidgetItem::setText方法的具体用法?C++ QListWidgetItem::setText怎么用?C++ QListWidgetItem::setText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QListWidgetItem
的用法示例。
在下文中一共展示了QListWidgetItem::setText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addMergeList
void DataMergeGui::addMergeList()
{
for (int i = 0; i < importTree->topLevelItemCount(); i++)
{
QTreeWidgetItem *topItem = importTree->topLevelItem(i);
for (int i = 0; i < topItem->childCount(); i++)
{
QTreeWidgetItem *childItem = topItem->child(i);
if (childItem->checkState(0) == Qt::Checked)
{
QString crtText = topItem->text(0);
if (flag == 0)
{
RasterElement *pFisrtElement = filenameMap[crtText.toStdString()];
RasterDataDescriptor* pFirstDesc = static_cast<RasterDataDescriptor*>(pFisrtElement->getDataDescriptor());
firstType = pFirstDesc->getDataType();
firstRowCount = pFirstDesc->getRowCount();
firstColCount = pFirstDesc->getColumnCount();
}
else
{
RasterElement *pTempElement = filenameMap[crtText.toStdString()];
RasterDataDescriptor* pTempDesc = static_cast<RasterDataDescriptor*>(pTempElement->getDataDescriptor());
EncodingType tempType = pTempDesc->getDataType();
int tempRowCount = pTempDesc->getRowCount();
int tempColCount = pTempDesc->getColumnCount();
if (firstType != tempType)
{
QMessageBox::critical(NULL, "Spectral Data Merge",
tr("Merge RasterElement %1 type different!").arg(crtText), "OK");
return;
}
if (firstRowCount != tempRowCount)
{
QMessageBox::critical(NULL, "Spectral Data Merge",
tr("Merge RasterElement %1 row different!").arg(crtText), "OK");
return;
}
if (firstColCount != tempColCount)
{
QMessageBox::critical(NULL, "Spectral Data Merge",
tr("Merge RasterElement column different!").arg(crtText), "OK");
return;
}
}
QListWidgetItem *item = new QListWidgetItem(mergeList);
item->setText(crtText + "--" + childItem->text(0));
// mergeElementList.push_back(filenameMap[crtText.toStdString()]);
removeButton->setEnabled(true);
mergeButton->setEnabled(true);
flag = 1;
}
}
//QListWidgetItem *crtItem = importList->currentItem();
/* QList<QListWidgetItem *> selectedList = importList->selectedItems();
for (int i = 0; i < selectedList.count(); i++)
{
QListWidgetItem *crtItem = selectedList.at(i);
QString crtText = crtItem->text();
if (flag == 0)
{
RasterElement *pFisrtElement = filenameMap[crtText.toStdString()];
RasterDataDescriptor* pFirstDesc = static_cast<RasterDataDescriptor*>(pFisrtElement->getDataDescriptor());
firstType = pFirstDesc->getDataType();
firstRowCount = pFirstDesc->getRowCount();
firstColCount = pFirstDesc->getColumnCount();
}
else
{
RasterElement *pTempElement = filenameMap[crtText.toStdString()];
RasterDataDescriptor* pTempDesc = static_cast<RasterDataDescriptor*>(pTempElement->getDataDescriptor());
EncodingType tempType = pTempDesc->getDataType();
int tempRowCount = pTempDesc->getRowCount();
int tempColCount = pTempDesc->getColumnCount();
if (firstType != tempType)
{
QMessageBox::critical(NULL, "Spectral Data Merge", "Merge RasterElement type different!", "OK");
return;
}
if (firstRowCount != tempRowCount)
{
QMessageBox::critical(NULL, "Spectral Data Merge", "Merge RasterElement row different!", "OK");
return;
}
if (firstColCount != tempColCount)
{
QMessageBox::critical(NULL, "Spectral Data Merge", "Merge RasterElement column different!", "OK");
return;
//.........这里部分代码省略.........
示例2: setCurrentItemLabel
void ItemOrderList::setCurrentItemLabel(const QString &label)
{
QListWidgetItem *current = ui->listWidgetItems->currentItem();
if(current != nullptr)
current->setText(label);
}
示例3: configurationRemoved
void BearerEx::configurationRemoved(const QNetworkConfiguration& config)
{
QListWidgetItem* listItem = new QListWidgetItem();
listItem->setText(QString("Removed: ")+config.name());
eventListWidget->addItem(listItem);
}
示例4: populateListWidget
bool DialogStartup::populateListWidget(QListWidget* lw,QString configPath) {
QFile xmlFile(configPath);
if (!xmlFile.exists() || (xmlFile.error() != QFile::NoError)) {
qDebug() << "ERROR: Unable to open config file " << configPath;
return false;
}
xmlFile.open(QIODevice::ReadOnly);
QXmlStreamReader reader(&xmlFile);
while (!reader.atEnd()) {
reader.readNext();
if (reader.isStartElement()) {
if (reader.name() == "demos")
while (!reader.atEnd()) {
reader.readNext();
if (reader.isStartElement() && reader.name() == "example") {
QXmlStreamAttributes attrs = reader.attributes();
QStringRef filename = attrs.value("filename");
if (!filename.isEmpty()) {
QStringRef name = attrs.value("name");
QStringRef image = attrs.value("image");
QStringRef args = attrs.value("args");
QStringRef idpocket = attrs.value("idpocket");
QStringRef desc = attrs.value("desc");
QStringRef _connectortype = attrs.value("connectortype");
QStringRef _conngender = attrs.value("conngender");
QListWidgetItem *newItem = new QListWidgetItem;
newItem->setText(name.toString());
newItem->setIcon(QIcon(image.toString()));
newItem->setData(Qt::UserRole,idpocket.toString());
if (!idpocket.startsWith("#"))
lw->addItem( newItem);
// filter on connectors type and gender
// if (!connType.isEmpty() && (_connectortype.indexOf(connType)==-1)) continue;
// qWarning()<<connType<<" found:"<<_connectortype;
// if (!connGender.isEmpty() && (_conngender.indexOf(connGender)==-1)) continue;
// qWarning()<<"included";
}
} else if(reader.isEndElement() && reader.name() == "demos") {
return true;
}
}
}
}
if (reader.hasError()) {
qDebug() << QString("Error parsing %1 on line %2 column %3: \n%4")
.arg(configPath)
.arg(reader.lineNumber())
.arg(reader.columnNumber())
.arg(reader.errorString());
}
return true;
}
示例5: readSMS
void QServer::readSMS(QString sms)
{
//Just display the message on GUI
QListWidgetItem * item = new QListWidgetItem(ui.listWidget);
item->setText(sms);
}
示例6: addDeviceToUsedDevList
//.........这里部分代码省略.........
name.append(QString("Video %1").arg(desc.toUpper()));
} else if ( device=="sound" ) {
// Sound
if (list.item(0).attributes().contains("model"))
desc = list.item(0).attributes().namedItem("model").nodeValue();
name.append(QString("Sound %1").arg(desc.toUpper()));
} else if ( device=="hostdev" ) {
// HostDevice
if (list.item(0).attributes().contains("type"))
desc = list.item(0).attributes().namedItem("type").nodeValue();
name.append(QString("Host Device %1").arg(desc.toUpper()));
} else if ( device=="graphics" ) {
// Graphics
if (list.item(0).attributes().contains("type"))
desc = list.item(0).attributes().namedItem("type").nodeValue();
name.append(QString("Display %1").arg(desc.toUpper()));
} else if ( device=="redirdev" ) {
// Redirected devices
if (list.item(0).attributes().contains("type"))
desc = list.item(0).attributes().namedItem("type").nodeValue();
name.append(QString("USB Redirector %1").arg(desc.toUpper()));
} else if ( device=="filesystem" ) {
// Filesystems
if (list.item(0).attributes().contains("type"))
desc = list.item(0).attributes().namedItem("type").nodeValue();
name.append(QString("Filesystem %1").arg(desc.toUpper()));
} else if ( device=="controller" ) {
// Controller
if (list.item(0).attributes().contains("type"))
desc = list.item(0).attributes().namedItem("type").nodeValue();
name.append(QString("Controller %1").arg(desc.toUpper()));
} else if ( device=="emulator" ) {
// Emulator
name.append(QString("Emulator"));
} else if ( device=="watchdog" ) {
// WatchDog
if (list.item(0).attributes().contains("model"))
desc = list.item(0).attributes().namedItem("model").nodeValue();
name.append(QString("WatchDog %1").arg(desc.toUpper()));
} else if ( device=="memballoon" ) {
// MemBalloon
if (list.item(0).attributes().contains("model"))
desc = list.item(0).attributes().namedItem("model").nodeValue();
name.append(QString("MemBalloon %1").arg(desc.toUpper()));
} else if ( device=="rng" ) {
// Random
if (list.item(0).attributes().contains("model"))
desc = list.item(0).attributes().namedItem("model").nodeValue();
name.append(QString("RNG %1").arg(desc.toUpper()));
} else if ( device=="tpm" ) {
// TPM
if (list.item(0).attributes().contains("model"))
desc = list.item(0).attributes().namedItem("model").nodeValue();
name.append(QString("TPM %1").arg(desc.toUpper()));
} else if ( device=="nvram" ) {
// NVRAM
name.append(QString("NVRAM"));
} else if ( device=="panic" ) {
// Panic
name.append(QString("Panic"));
} else return;
// find DeviceName in Order
int i = -1;
foreach (QString _name, devNameOrder) {
if ( name.startsWith(_name) ) {
i = devNameOrder.indexOf(_name);
break;
};
};
// impossible case, but...
if (i<0) return;
// insert item by Device Name Order
bool inserted = false;
do {
int row = 0;
QList<QListWidgetItem*> _family =
usedDeviceList->findItems(
devNameOrder.at(i),
Qt::MatchCaseSensitive | Qt::MatchStartsWith);
if ( _family.isEmpty() ) {
if ( i>0) {
--i;
continue;
};
} else {
QListWidgetItem *lastItem = _family.last();
row = usedDeviceList->row( lastItem ) + 1;
};
QListWidgetItem *item = new QListWidgetItem();
item->setText(name);
item->setData(Qt::UserRole, doc.toString());
usedDeviceList->insertItem(row, item);
//usedDeviceList->insertItem(row, name);
//usedDeviceList->item(row)->setData(Qt::UserRole, doc.toString());
showDevice(item, NULL);
inserted = true;
} while ( !inserted );
//qDebug()<<"added New Device:"<<name;
initBootDevices();
}
示例7: populateConnections
bool QgsManageConnectionsDialog::populateConnections()
{
// Export mode. Populate connections list from settings
if ( mDialogMode == Export )
{
QSettings settings;
switch ( mConnectionType )
{
case WMS:
settings.beginGroup( "/Qgis/connections-wms" );
break;
case WFS:
settings.beginGroup( "/Qgis/connections-wfs" );
break;
case PostGIS:
settings.beginGroup( "/PostgreSQL/connections" );
break;
}
QStringList keys = settings.childGroups();
QStringList::Iterator it = keys.begin();
while ( it != keys.end() )
{
QListWidgetItem *item = new QListWidgetItem();
item->setText( *it );
listConnections->addItem( item );
++it;
}
settings.endGroup();
}
// Import mode. Populate connections list from file
else
{
QFile file( mFileName );
if ( !file.open( QIODevice::ReadOnly | QIODevice::Text ) )
{
QMessageBox::warning( this, tr( "Loading connections" ),
tr( "Cannot read file %1:\n%2." )
.arg( mFileName )
.arg( file.errorString() ) );
return false;
}
QDomDocument doc;
QString errorStr;
int errorLine;
int errorColumn;
if ( !doc.setContent( &file, true, &errorStr, &errorLine, &errorColumn ) )
{
QMessageBox::warning( this, tr( "Loading connections" ),
tr( "Parse error at line %1, column %2:\n%3" )
.arg( errorLine )
.arg( errorColumn )
.arg( errorStr ) );
return false;
}
QDomElement root = doc.documentElement();
switch ( mConnectionType )
{
case WMS:
if ( root.tagName() != "qgsWMSConnections" )
{
QMessageBox::information( this, tr( "Loading connections" ),
tr( "The file is not an WMS connections exchange file." ) );
return false;
}
break;
case WFS:
if ( root.tagName() != "qgsWFSConnections" )
{
QMessageBox::information( this, tr( "Loading connections" ),
tr( "The file is not an WFS connections exchange file." ) );
return false;
}
break;
case PostGIS:
if ( root.tagName() != "qgsPgConnections" )
{
QMessageBox::information( this, tr( "Loading connections" ),
tr( "The file is not an PostGIS connections exchange file." ) );
return false;
}
break;
}
QDomElement child = root.firstChildElement();
while ( !child.isNull() )
{
QListWidgetItem *item = new QListWidgetItem();
item->setText( child.attribute( "name" ) );
listConnections->addItem( item );
child = child.nextSiblingElement();
}
}
return true;
}
示例8: updateListOfModes
void TaskDatumParameters::updateListOfModes(eMapMode curMode)
{
//first up, remember currently selected mode.
if (curMode == mmDeactivated){
auto sel = ui->listOfModes->selectedItems();
if (sel.count() > 0)
curMode = modesInList[ui->listOfModes->row(sel[0])];
}
//obtain list of available modes:
Part::Datum* pcDatum = static_cast<Part::Datum*>(DatumView->getObject());
this->lastSuggestResult.bestFitMode = mmDeactivated;
size_t lastValidModeItemIndex = mmDummy_NumberOfModes;
if (pcDatum->Support.getSize() > 0){
pcDatum->attacher().suggestMapModes(this->lastSuggestResult);
modesInList = this->lastSuggestResult.allApplicableModes;
//add reachable modes to the list, too, but gray them out (using lastValidModeItemIndex, later)
lastValidModeItemIndex = modesInList.size()-1;
for(std::pair<const eMapMode, refTypeStringList> &rm: this->lastSuggestResult.reachableModes){
modesInList.push_back(rm.first);
}
} else {
//no references - display all modes
modesInList.clear();
for( int mmode = 0 ; mmode < mmDummy_NumberOfModes ; mmode++){
if (pcDatum->attacher().modeEnabled[mmode])
modesInList.push_back(eMapMode(mmode));
}
}
//populate list
ui->listOfModes->blockSignals(true);
ui->listOfModes->clear();
QListWidgetItem* iSelect = 0;
if (modesInList.size()>0) {
for (size_t i = 0 ; i < modesInList.size() ; ++i){
eMapMode mmode = modesInList[i];
std::vector<QString> mstr = AttacherGui::getUIStrings(pcDatum->attacher().getTypeId(),mmode);
ui->listOfModes->addItem(mstr[0]);
QListWidgetItem* item = ui->listOfModes->item(i);
item->setToolTip(mstr[1] + QString::fromLatin1("\n\n") +
tr("Reference combinations:\n") +
AttacherGui::getRefListForMode(pcDatum->attacher(),mmode).join(QString::fromLatin1("\n")));
if (mmode == curMode)
iSelect = ui->listOfModes->item(i);
if (i > lastValidModeItemIndex){
//potential mode - can be reached by selecting more stuff
item->setFlags(item->flags() & ~(Qt::ItemFlag::ItemIsEnabled | Qt::ItemFlag::ItemIsSelectable));
refTypeStringList &extraRefs = this->lastSuggestResult.reachableModes[mmode];
if (extraRefs.size() == 1){
QStringList buf;
for(eRefType rt : extraRefs[0]){
buf.append(AttacherGui::getShapeTypeText(rt));
}
item->setText(tr("%1 (add %2)").arg(
item->text(),
buf.join(QString::fromLatin1("+"))
));
} else {
item->setText(tr("%1 (add more references)").arg(item->text()));
}
} else if (mmode == this->lastSuggestResult.bestFitMode){
//suggested mode - make bold
assert (item);
QFont fnt = item->font();
fnt.setBold(true);
item->setFont(fnt);
}
}
}
//restore selection
ui->listOfModes->selectedItems().clear();
if (iSelect)
iSelect->setSelected(true);
ui->listOfModes->blockSignals(false);
}
示例9: getManipulator
QWidget* EditCallDialog::getManipulator(const FunctionCall::Argument *arg)
{
QWidget *w;
switch(arg->iType) {
case DBG_TYPE_CHAR:
w = new QSpinBox(this);
((QSpinBox*)w)->setRange(CHAR_MIN, CHAR_MAX);
((QSpinBox*)w)->setValue(*(char*)arg->pData);
break;
case DBG_TYPE_UNSIGNED_CHAR:
w = new QSpinBox(this);
((QSpinBox*)w)->setRange(0, UCHAR_MAX);
((QSpinBox*)w)->setValue(*(unsigned char*)arg->pData);
break;
case DBG_TYPE_SHORT_INT:
w = new QSpinBox(this);
((QSpinBox*)w)->setRange(SHRT_MIN, SHRT_MAX);
((QSpinBox*)w)->setValue(*(short*)arg->pData);
break;
case DBG_TYPE_UNSIGNED_SHORT_INT:
w = new QSpinBox(this);
((QSpinBox*)w)->setRange(0, USHRT_MAX);
((QSpinBox*)w)->setValue(*(unsigned short*)arg->pData);
break;
case DBG_TYPE_INT:
w = new QSpinBox(this);
((QSpinBox*)w)->setRange(INT_MIN, INT_MAX);
((QSpinBox*)w)->setValue(*(int*)arg->pData);
break;
case DBG_TYPE_UNSIGNED_INT:
w = new QSpinBox(this);
//((QSpinBox*)w)->setRange(0, UINT_MAX);
((QSpinBox*)w)->setRange(0, INT_MAX);
((QSpinBox*)w)->setValue(*(unsigned int*)arg->pData);
break;
case DBG_TYPE_LONG_INT:
w = new QSpinBox(this);
//((QSpinBox*)w)->setRange(LONG_MIN, LONG_MAX);
((QSpinBox*)w)->setRange(INT_MIN, INT_MAX);
((QSpinBox*)w)->setValue(*(long*)arg->pData);
break;
case DBG_TYPE_UNSIGNED_LONG_INT:
w = new QSpinBox(this);
//((QSpinBox*)w)->setRange(0, ULONG_MAX);
((QSpinBox*)w)->setRange(0, INT_MAX);
((QSpinBox*)w)->setValue(*(unsigned long*)arg->pData);
break;
case DBG_TYPE_LONG_LONG_INT:
w = new QSpinBox(this);
//((QSpinBox*)w)->setRange(LLONG_MIN, LLONG_MAX);
((QSpinBox*)w)->setRange(INT_MIN, INT_MAX);
((QSpinBox*)w)->setValue(*(long long*)arg->pData);
break;
case DBG_TYPE_UNSIGNED_LONG_LONG_INT:
w = new QSpinBox(this);
//((QSpinBox*)w)->setRange(0, ULLONG_MAX);
((QSpinBox*)w)->setRange(0, INT_MAX);
((QSpinBox*)w)->setValue(*(unsigned long long*)arg->pData);
break;
case DBG_TYPE_FLOAT:
w = new QDoubleSpinBox(this);
((QDoubleSpinBox*)w)->setRange(-FLT_MAX, FLT_MAX);
((QDoubleSpinBox*)w)->setDecimals(6);
((QDoubleSpinBox*)w)->setValue(*(float*)arg->pData);
break;
case DBG_TYPE_DOUBLE:
w = new QDoubleSpinBox(this);
((QDoubleSpinBox*)w)->setRange(-DBL_MAX, DBL_MAX);
((QDoubleSpinBox*)w)->setDecimals(6);
((QDoubleSpinBox*)w)->setValue(*(float*)arg->pData);
break;
case DBG_TYPE_POINTER:
{
char *s;
w = new QLineEdit(this);
((QLineEdit*)w)->setEnabled(false);
asprintf(&s, "%p", *(void**)arg->pData);
((QLineEdit*)w)->setText(s);
break;
}
case DBG_TYPE_BOOLEAN:
w = new QComboBox(this);
((QComboBox*)w)->addItem("false");
((QComboBox*)w)->addItem("true");
((QComboBox*)w)->setCurrentIndex(*(bool*)arg->pData);
break;
case DBG_TYPE_BITFIELD:
{
int i = 0;
GLbitfield b = *(GLbitfield*)arg->pData;
w = new QListWidget(this);
((QListWidget*)w)->setSortingEnabled(true);
((QListWidget*)w)->setSelectionMode(
QAbstractItemView::MultiSelection);
while (glBitfieldMap[i].string != NULL) {
QListWidgetItem *item = new QListWidgetItem((QListWidget*) w);
item->setText(QString(glBitfieldMap[i].string));
item->setData(Qt::UserRole, QVariant(glBitfieldMap[i].value));
if ((glBitfieldMap[i].value & b) == glBitfieldMap[i].value) {
item->setSelected(true);
//.........这里部分代码省略.........
示例10: CarregaAlmoco
void Almoco::CarregaAlmoco( bool bCarregarUltimoAlmoco )
{
if( operacao == CARREGANDO )
return ;
QSqlQuery sql( db );
QString consulta;
QString sWhere;
double dValorAlmoco = 0;
double dValorVoce = 0;
double dValorEmpresa = 0;
bool bTodos = false;
QString sCodigoEmpresa = ui->comboBox_restaurantesLancamento->itemData( ui->comboBox_restaurantesLancamento->currentIndex() ).toString() ;
this->setEnabled( false );
if( ui->comboBox_restaurantesLancamento->currentText() == "Todos" )
bTodos = true;
//consulta = "select almoco.*, restaurante.nome, restaurante.valor as valorRestaurante from almoco left join restaurante on almoco.restaurante = restaurante.codigo ";
consulta = "select almoco.*, ifnull( restaurante.nome, 'Não informado') as nomerestaurante, "
"case when restaurante.valor is null then almoco.valor else almoco.valor - restaurante.valor end as valorvoce,"
"ifnull( restaurante.valor, 0 ) as valorempresa from almoco "
"left join restaurante on almoco.restaurante = restaurante.codigo ";
if( bTodos )
{
sWhere = " where almoco.dtcadastro between '" + ui->dateEdit_filtro->date().toString("yyyy-MM-dd") + "' and '" + ui->dateEdit_filtroAte->date().toString("yyyy-MM-dd") + "' " ;
}
else
{
if( sCodigoEmpresa.isEmpty() )
sCodigoEmpresa = "0";
sWhere = " where almoco.restaurante = " + sCodigoEmpresa + " and almoco.dtcadastro between '" + ui->dateEdit_filtro->date().toString("yyyy-MM-dd") + "' and '" + ui->dateEdit_filtroAte->date().toString("yyyy-MM-dd") + "' ";
}
consulta += sWhere ;
if( bCarregarUltimoAlmoco and !bTodos )
{
int iQtd = ui->listWidget_lista->count();
if( iQtd > 0 )
{
consulta.append( " and almoco.codigo > " + ui->listWidget_lista->item( iQtd - 1 )->whatsThis() );
}
}
else
{
ui->listWidget_lista->clear();
}
consulta += " order by dtcadastro desc";
if( !sql.exec( consulta ) )
{
Funcoes::ErroSQL( sql, "CarregaAlmoco", this);
this->setEnabled( true );
return ;
}
//else
// Funcoes::MensagemAndroid( "Carrega almoço", sql.lastQuery(), "Aperte", this );
while( sql.next() )
{
QListWidgetItem *novoItem = new QListWidgetItem( );
novoItem->setText( "Data: " + sql.record().value("dtcadastro").toDate().toString("dd-MM-yyyy")
+ "\nValor: " + NumeroParaMoeda( sql.record().value("valor").toString() )
+ "\nRestaurante: " + sql.record().value("nomerestaurante").toString() );
novoItem->setWhatsThis( sql.record().value("codigo").toString() );
ui->listWidget_lista->addItem( novoItem );
dValorAlmoco += sql.record().value("valor").toDouble();
dValorEmpresa += sql.record().value("valorempresa").toDouble();
dValorVoce += sql.record().value("valorvoce").toDouble();
}
ui->label_almoco->setText( Funcoes::NumeroParaMoeda( QString::number( dValorAlmoco ) ) );
ui->label_empresa->setText( Funcoes::NumeroParaMoeda( QString::number( dValorEmpresa ) ) );
ui->label_voce->setText( Funcoes::NumeroParaMoeda( QString::number( dValorVoce ) ) );
this->setEnabled( true );
//ui->listWidget_lista->scrollBarWidgets();
}
示例11: addDirectoryToPreview
int QgsComposerPictureWidget::addDirectoryToPreview( const QString& path )
{
//go through all files of a directory
QDir directory( path );
if ( !directory.exists() || !directory.isReadable() )
{
return 1; //error
}
QFileInfoList fileList = directory.entryInfoList( QDir::Files );
QFileInfoList::const_iterator fileIt = fileList.constBegin();
QProgressDialog progress( "Adding Icons...", "Abort", 0, fileList.size() - 1, this );
//cancel button does not seem to work properly with modal dialog
//progress.setWindowModality(Qt::WindowModal);
int counter = 0;
for ( ; fileIt != fileList.constEnd(); ++fileIt )
{
progress.setLabelText( tr( "Creating icon for file %1" ).arg( fileIt->fileName() ) );
progress.setValue( counter );
QCoreApplication::processEvents();
if ( progress.wasCanceled() )
{
break;
}
QString filePath = fileIt->absoluteFilePath();
//test if file is svg or pixel format
bool fileIsPixel = false;
bool fileIsSvg = testSvgFile( filePath );
if ( !fileIsSvg )
{
fileIsPixel = testImageFile( filePath );
}
//exclude files that are not svg or image
if ( !fileIsSvg && !fileIsPixel )
{
++counter; continue;
}
QListWidgetItem * listItem = new QListWidgetItem( mPreviewListWidget );
listItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
if ( fileIsSvg )
{
QIcon icon( filePath );
listItem->setIcon( icon );
}
else if ( fileIsPixel ) //for pixel formats: create icon from scaled pixmap
{
QPixmap iconPixmap( filePath );
if ( iconPixmap.isNull() )
{
++counter; continue; //unknown file format or other problem
}
//set pixmap hardcoded to 30/30, same as icon size for mPreviewListWidget
QPixmap scaledPixmap( iconPixmap.scaled( QSize( 30, 30 ), Qt::KeepAspectRatio ) );
QIcon icon( scaledPixmap );
listItem->setIcon( icon );
}
else
{
++counter; continue;
}
listItem->setText( "" );
//store the absolute icon file path as user data
listItem->setData( Qt::UserRole, fileIt->absoluteFilePath() );
++counter;
}
return 0;
}
示例12: addItem
void PrefAssociations::addItem(QString label)
{
QListWidgetItem* item = new QListWidgetItem(listWidget);
item->setText(label);
}
示例13: QDialog
// Constructor
AtenPrefs::AtenPrefs(AtenWindow& parent) : QDialog(&parent), parent_(parent)
{
ui.setupUi(this);
// Add colour popups to buttons
ui.ElementColourButton->setPopupWidget(new ColourPopup(parent_, ui.ElementColourButton), true);
connect(ui.ElementColourButton->popupWidget(), SIGNAL(popupDone()), this, SLOT(elementColourChanged()));
ui.SpotlightAmbientColourButton->setPopupWidget(new ColourPopup(parent_, ui.SpotlightAmbientColourButton, TColourWidget::NoAlphaOption), true);
connect(ui.SpotlightAmbientColourButton->popupWidget(), SIGNAL(popupDone()), this, SLOT(spotlightAmbientChanged()));
ui.SpotlightDiffuseColourButton->setPopupWidget(new ColourPopup(parent_, ui.SpotlightDiffuseColourButton, TColourWidget::NoAlphaOption), true);
connect(ui.SpotlightDiffuseColourButton->popupWidget(), SIGNAL(popupDone()), this, SLOT(spotlightDiffuseChanged()));
ui.SpotlightSpecularColourButton->setPopupWidget(new ColourPopup(parent_, ui.SpotlightSpecularColourButton, TColourWidget::NoAlphaOption), true);
connect(ui.SpotlightSpecularColourButton->popupWidget(), SIGNAL(popupDone()), this, SLOT(spotlightSpecularChanged()));
refreshing_ = false;
// Add elements to element list and select first item
QListWidgetItem* item;
for (int i=0; i<ElementMap::nElements(); ++i)
{
item = new QListWidgetItem(ui.ElementList);
item->setText(ElementMap::name(i));
}
refreshing_ = true;
// Select the first element in the elements list
ui.ElementList->setCurrentRow(0);
// Set Controls
// View Page - Style Tab
ui.StickRadiusSpin->setValue(prefs.atomStyleRadius(Prefs::LineStyle));
ui.TubeRadiusSpin->setValue(prefs.atomStyleRadius(Prefs::TubeStyle));
ui.SphereRadiusSpin->setValue(prefs.atomStyleRadius(Prefs::SphereStyle));
ui.ScaledRadiusSpin->setValue(prefs.atomStyleRadius(Prefs::ScaledStyle));
ui.StickBondRadiusSpin->setValue(prefs.bondStyleRadius(Prefs::LineStyle));
ui.TubeBondRadiusSpin->setValue(prefs.bondStyleRadius(Prefs::TubeStyle));
ui.SphereBondRadiusSpin->setValue(prefs.bondStyleRadius(Prefs::SphereStyle));
ui.ScaledBondRadiusSpin->setValue(prefs.bondStyleRadius(Prefs::ScaledStyle));
ui.SelectionScaleSpin->setValue(prefs.selectionScale());
ui.AngleLabelFormatEdit->setText(prefs.angleLabelFormat());
ui.DistanceLabelFormatEdit->setText(prefs.distanceLabelFormat());
ui.ChargeLabelFormatEdit->setText(prefs.chargeLabelFormat());
ui.LabelSizeSpin->setValue(prefs.labelSize());
ui.RenderDashedAromaticsCheck->setChecked(prefs.renderDashedAromatics());
ui.DrawHydrogenBondsCheck->setChecked(prefs.drawHydrogenBonds());
ui.HydrogenBondDotRadiusSpin->setValue(prefs.hydrogenBondDotRadius());
ui.StickLineNormalWidthSpin->setValue(prefs.stickLineNormalWidth());
ui.StickLineSelectedWidthSpin->setValue(prefs.stickLineSelectedWidth());
// View Page - Colours Tab
ui.ColoursTable->setRowCount(Prefs::nObjectColours);
QColor qcol;
for (int n = 0; n < Prefs::nObjectColours; ++n)
{
QTableWidgetItem *item = new QTableWidgetItem(Prefs::objectColourName( (Prefs::ObjectColour) n ));
ui.ColoursTable->setItem(n, 0, item);
item = new QTableWidgetItem();
double* colour = prefs.colour( (Prefs::ObjectColour) n );
qcol.setRgbF( colour[0], colour[1], colour[2], colour[3] );
item->setBackgroundColor(qcol);
ui.ColoursTable->setItem(n, 1, item);
}
// View Page - Rendering / Quality tab
ReturnValue rv;
rv.setArray(VTypes::DoubleData, prefs.spotlightColour(Prefs::AmbientComponent), 4);
ui.SpotlightAmbientColourButton->callPopupMethod("setCurrentColour", rv);
rv.setArray(VTypes::DoubleData, prefs.spotlightColour(Prefs::DiffuseComponent), 4);
ui.SpotlightDiffuseColourButton->callPopupMethod("setCurrentColour", rv);
rv.setArray(VTypes::DoubleData, prefs.spotlightColour(Prefs::SpecularComponent), 4);
ui.SpotlightSpecularColourButton->callPopupMethod("setCurrentColour", rv);
double* pos = prefs.spotlightPosition();
ui.SpotlightPositionXSpin->setValue(pos[0]);
ui.SpotlightPositionYSpin->setValue(pos[1]);
ui.SpotlightPositionZSpin->setValue(pos[2]);
ui.ShininessSpin->setValue(prefs.shininess());
ui.PrimitiveQualitySpin->setValue(prefs.primitiveQuality());
ui.ImagePrimitiveQualitySpin->setValue(prefs.imagePrimitiveQuality());
ui.ImagePrimitivesGroup->setChecked(!prefs.reusePrimitiveQuality());
ui.LineAliasingCheck->setChecked(prefs.lineAliasing());
ui.PolygonAliasingCheck->setChecked(prefs.polygonAliasing());
ui.MultiSamplingCheck->setChecked(prefs.multiSampling());
ui.NearClipSpin->setValue(prefs.clipNear());
ui.FarClipSpin->setValue(prefs.clipFar());
ui.NearDepthSpin->setValue(prefs.depthNear());
ui.FarDepthSpin->setValue(prefs.depthFar());
// View Page - Fonts tab
ui.ViewerFontEdit->setText(prefs.viewerFontFileName());
ui.MessagesSizeSpin->setValue(prefs.messagesFont().pixelSize());
// Set controls in interaction page
ui.LeftMouseCombo->setCurrentIndex(prefs.mouseAction(Prefs::LeftButton));
ui.MiddleMouseCombo->setCurrentIndex(prefs.mouseAction(Prefs::MiddleButton));
ui.RightMouseCombo->setCurrentIndex(prefs.mouseAction(Prefs::RightButton));
ui.WheelMouseCombo->setCurrentIndex(prefs.mouseAction(Prefs::WheelButton));
ui.ShiftButtonCombo->setCurrentIndex(prefs.keyAction(Prefs::ShiftKey));
ui.CtrlButtonCombo->setCurrentIndex(prefs.keyAction(Prefs::CtrlKey));
//.........这里部分代码省略.........
示例14: nuevoCliente
void Rec::nuevoCliente(int cliente) {
QListWidgetItem *item = new QListWidgetItem;
item->setText(QString::number(cliente));
conectados->addItem(item);
}
示例15: QDialog
CEphList::CEphList(QWidget *parent, mapView_t *view) :
QDialog(parent),
ui(new Ui::CEphList)
{
ui->setupUi(this);
cELColumn[0] = tr("JD");
cELColumn[1] = tr("Date");
cELColumn[2] = tr("Time");
cELColumn[3] = tr("Magnitude");
cELColumn[4] = tr("Phase");
cELColumn[5] = tr("Position angle");
cELColumn[6] = tr("Size X");
cELColumn[7] = tr("Size Y");
cELColumn[8] = tr("Local R.A.");
cELColumn[9] = tr("Local Dec.");
cELColumn[10] = tr("Local R.A. (J2000.0)");
cELColumn[11] = tr("Local Dec. (J2000.0)");
cELColumn[12] = tr("Geo. R.A.");
cELColumn[13] = tr("Geo. Dec.");
cELColumn[14] = tr("Azimuth");
cELColumn[15] = tr("Altitude");
cELColumn[16] = tr("Dist. to Earth (R)");
cELColumn[17] = tr("Helio. dist. (r)");
cELColumn[18] = tr("Elongation");
cELColumn[19] = tr("Helio. longitude");
cELColumn[20] = tr("Helio. latitude");
cELColumn[21] = tr("Helio. rect. X");
cELColumn[22] = tr("Helio. rect. Y");
cELColumn[23] = tr("Helio. rect. Z");
cELColumn[24] = tr("Light time");
if (firstTime)
{
for (int i = 0; i < EL_COLUMN_COUNT; i++)
{
bChecked[i] = Qt::Checked;
columnOrder[i] = i;
}
}
m_view = *view;
ui->comboBox->addItem(tr("Minute(s)"));
ui->comboBox->addItem(tr("Hour(s)"));
ui->comboBox->addItem(tr("Day(s)"));
for (int i = 0; i < EL_COLUMN_COUNT; i++)
{
QListWidgetItem *item = new QListWidgetItem;
item->setText(cELColumn[columnOrder[i]]);
item->setFlags(Qt::ItemIsSelectable |
Qt::ItemIsUserCheckable |
Qt::ItemIsEnabled);
item->setCheckState(bChecked[columnOrder[i]]);
item->setData(Qt::UserRole + 1, columnOrder[i]);
ui->listWidget_2->addItem(item);
}
for (int i = 0; i < PT_PLANET_COUNT; i++)
{
QListWidgetItem *item = new QListWidgetItem;
item->setText(cAstro.getName(i));
ui->listWidget->addItem(item);
}
for (int i = 0; i < tComets.count(); i++)
{
if (tComets[i].selected)
{
QListWidgetItem *item = new QListWidgetItem;
item->setText(tComets[i].name);
item->setData(Qt::UserRole + 1, i);
ui->listWidget_3->addItem(item);
}
}
for (int i = 0; i < tAsteroids.count(); i++)
{
if (tAsteroids[i].selected)
{
QListWidgetItem *item = new QListWidgetItem;
item->setText(tAsteroids[i].name);
item->setData(Qt::UserRole + 1, i);
ui->listWidget_4->addItem(item);
}
}
ui->checkBox->setChecked(isUTC);
ui->comboBox->setCurrentIndex(nCombo);
ui->spinBox->setValue(nStep);
if (firstTime)
{
QDateTime t;
//.........这里部分代码省略.........