本文整理汇总了C++中QComboBox::setItemIcon方法的典型用法代码示例。如果您正苦于以下问题:C++ QComboBox::setItemIcon方法的具体用法?C++ QComboBox::setItemIcon怎么用?C++ QComboBox::setItemIcon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QComboBox
的用法示例。
在下文中一共展示了QComboBox::setItemIcon方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QComboBox
QWidget *BackgroundAction::createWidget(QWidget *parent)
{
QComboBox *comboBox = new QComboBox(parent);
comboBox->setFixedWidth(42);
for (int i = 0; i < colors().count(); ++i) {
comboBox->addItem(tr(""));
comboBox->setItemIcon(i, iconForColor((colors().at(i))));
}
comboBox->setCurrentIndex(0);
connect(comboBox, SIGNAL(currentIndexChanged(int)), SLOT(emitBackgroundChanged(int)));
comboBox->setProperty("hideborder", true);
return comboBox;
}
示例2: updateTable
//.........这里部分代码省略.........
for (i=0; i<ASCII_OPEN_DLG_TYPES_NUMBER; i++)
propsText << QString(ASCII_OPEN_DLG_TYPES_NAMES[i]);
//remove unnecessary columns
while (columnsCount<m_columnsCount)
tableWidget->removeColumn(--m_columnsCount);
for (i=lineCount+1; i<=DISPLAYED_LINES; ++i)
tableWidget->removeRow(i);
int columnWidth = (tableWidget->width()*9) / (columnsCount*10);
columnWidth = ccMax(columnWidth,80);
//Icons
const QIcon xIcon(QString::fromUtf8(":/CC/Types/images/types/x_coordinate.png"));
const QIcon yIcon(QString::fromUtf8(":/CC/Types/images/types/y_coordinate.png"));
const QIcon zIcon(QString::fromUtf8(":/CC/Types/images/types/z_coordinate.png"));
const QIcon NormIcon(QString::fromUtf8(":/CC/Types/images/types/normal.png"));
const QIcon RGBIcon(QString::fromUtf8(":/CC/Types/images/types/rgb_color.png"));
const QIcon GreyIcon(QString::fromUtf8(":/CC/Types/images/types/gray_color.png"));
const QIcon ScalarIcon(QString::fromUtf8(":/CC/Types/images/types/scalar_field.png"));
const QIcon PositiveScalarIcon(QString::fromUtf8(":/CC/Types/images/types/positive_scalar_field.png"));
unsigned assignedXYZ = 0;
unsigned assignedNorm = 0;
unsigned assignedRGB = 0;
for (i=0; i<columnsCount; i++)
{
QComboBox* columnHeader = static_cast<QComboBox*>(tableWidget->cellWidget(0,i));
QComboBox* _columnHeader = columnHeader;
if (!columnHeader)
{
columnHeader = new QComboBox();
columnHeader->addItems(propsText);
columnHeader->setMaxVisibleItems(ASCII_OPEN_DLG_TYPES_NUMBER);
columnHeader->setCurrentIndex(0);
columnHeader->setItemIcon(ASCII_OPEN_DLG_X,xIcon);
columnHeader->setItemIcon(ASCII_OPEN_DLG_Y,yIcon);
columnHeader->setItemIcon(ASCII_OPEN_DLG_Z,zIcon);
columnHeader->setItemIcon(ASCII_OPEN_DLG_NX,NormIcon);
columnHeader->setItemIcon(ASCII_OPEN_DLG_NY,NormIcon);
columnHeader->setItemIcon(ASCII_OPEN_DLG_NZ,NormIcon);
columnHeader->setItemIcon(ASCII_OPEN_DLG_R,RGBIcon);
columnHeader->setItemIcon(ASCII_OPEN_DLG_G,RGBIcon);
columnHeader->setItemIcon(ASCII_OPEN_DLG_B,RGBIcon);
columnHeader->setItemIcon(ASCII_OPEN_DLG_Grey,GreyIcon);
columnHeader->setItemIcon(ASCII_OPEN_DLG_Scalar,ScalarIcon);
columnHeader->setItemIcon(ASCII_OPEN_DLG_Positive_Scalar,PositiveScalarIcon);
connect(columnHeader, SIGNAL(currentIndexChanged(int)), this, SLOT(columnsTypeHasChanged(int)));
}
if (valueIsNumber[i])
{
//first time? let's try to assign each column a type
if ((m_invalidColumns || m_columnsCount==0) && columnsCount>1)
{
columnHeader->blockSignals(true);
//by default, we assume that the first columns are always X,Y and Z
if (assignedXYZ<3)
{
//in rare cases, the first column is an index
if (assignedXYZ==0 && valueIsInteger[i] && (i+1<columnsCount) && !valueIsInteger[i+1])
{
//we skip it
}
else
{
++assignedXYZ;
columnHeader->setCurrentIndex(assignedXYZ);
}
}
else
{
//looks like RGB?
if (valueIsBelow255[i] && assignedRGB<3 && (i+2-assignedRGB < columnsCount)
&& (assignedRGB > 0 || (valueIsBelow255[i+1] && valueIsBelow255[i+2]))) //make sure that next values are also ok!
{
columnHeader->setCurrentIndex(ASCII_OPEN_DLG_R+assignedRGB);
++assignedRGB;
}
else if (valueIsBelowOne[i] && assignedNorm<3 && (i+2-assignedNorm < columnsCount)
&& (assignedNorm > 0 || (valueIsBelowOne[i+1] && valueIsBelowOne[i+2]))) //make sure that next values are also ok!
{
columnHeader->setCurrentIndex(ASCII_OPEN_DLG_NX+assignedNorm);
++assignedNorm;
}
else
{
//maybe it's a scalar?
columnHeader->setCurrentIndex(ASCII_OPEN_DLG_Scalar);
}
}
columnHeader->blockSignals(false);
}
}
if (!_columnHeader)
tableWidget->setCellWidget(0,i,columnHeader);
tableWidget->setColumnWidth(i,columnWidth);
}
示例3: updateIconComboBox
/**
* Updates the icon combobox depending on user's selection
*/
void OptionsDialog::updateIconComboBox(int index) {
if (isRemIns == true)
return;
QString objName = QObject::sender()->objectName();
if (objName.endsWith("2")) {
p2Icon += index;
return;
}
QComboBox *cBoxR = combop2;
if (iconType == 0) {
if (index == 0) {
cBoxR->setItemIcon(0, *classicIcons[1]);
cBoxR->setItemText(0, tr("White"));
p2Icon = 0;
}
else {
cBoxR->setItemIcon(0, *classicIcons[0]);
cBoxR->setItemText(0, tr("Black"));
p2Icon = 1;
}
}
else if (iconType == 1) {
if (index == 0) {
cBoxR->setItemIcon(0, *osIcons[1]);
cBoxR->setItemText(0, tr("Debian"));
cBoxR->setItemIcon(1, *osIcons[2]);
cBoxR->setItemText(1, tr("MacOS"));
cBoxR->setItemIcon(2, *osIcons[3]);
cBoxR->setItemText(2, tr("Windows"));
p2Icon = 1;
} else if (index == 1) {
cBoxR->setItemIcon(0, *osIcons[0]);
cBoxR->setItemText(0, tr("ArchLinux"));
cBoxR->setItemIcon(1, *osIcons[2]);
cBoxR->setItemText(1, tr("MacOS"));
cBoxR->setItemIcon(2, *osIcons[3]);
cBoxR->setItemText(2, tr("Windows"));
p2Icon = 0;
} else if (index == 2) {
cBoxR->setItemIcon(0, *osIcons[0]);
cBoxR->setItemText(0, tr("ArchLinux"));
cBoxR->setItemIcon(1, *osIcons[1]);
cBoxR->setItemText(1, tr("Debian"));
cBoxR->setItemIcon(2, *osIcons[3]);
cBoxR->setItemText(2, tr("Windows"));
p2Icon = 0;
} else {
cBoxR->setItemIcon(0, *osIcons[0]);
cBoxR->setItemText(0, tr("ArchLinux"));
cBoxR->setItemIcon(1, *osIcons[1]);
cBoxR->setItemText(1, tr("Debian"));
cBoxR->setItemIcon(2, *osIcons[2]);
cBoxR->setItemText(2, tr("MacOS"));
p2Icon = 0;
}
} else if (iconType == 2) {
if (index == 0) {
cBoxR->setItemIcon(0, *progIcons[1]);
cBoxR->setItemText(0, tr("Java"));
cBoxR->setItemIcon(1, *progIcons[2]);
cBoxR->setItemText(1, tr("Qt"));
p2Icon = 1;
} else if (index == 1) {
cBoxR->setItemIcon(0, *progIcons[0]);
cBoxR->setItemText(0, tr("C"));
cBoxR->setItemIcon(1, *progIcons[2]);
cBoxR->setItemText(1, tr("Qt"));
p2Icon = 0;
} else {
cBoxR->setItemIcon(0, *progIcons[0]);
cBoxR->setItemText(0, tr("C"));
cBoxR->setItemIcon(1, *progIcons[1]);
cBoxR->setItemText(1, tr("Java"));
p2Icon = 0;
}
} else {
if (index == 0) {
cBoxR->setItemIcon(0, *teamIcons[1]);
cBoxR->setItemText(0, tr("OSFP"));
cBoxR->setItemIcon(1, *teamIcons[2]);
cBoxR->setItemText(1, tr("PAO"));
p2Icon = 1;
} else if (index == 1) {
cBoxR->setItemIcon(0, *teamIcons[0]);
cBoxR->setItemText(0, tr("AEK"));
cBoxR->setItemIcon(1, *teamIcons[2]);
cBoxR->setItemText(1, tr("PAO"));
p2Icon = 0;
} else {
cBoxR->setItemIcon(0, *teamIcons[0]);
cBoxR->setItemText(0, tr("AEK"));
cBoxR->setItemIcon(1, *teamIcons[1]);
cBoxR->setItemText(1, tr("OSFP"));
//.........这里部分代码省略.........
示例4: px
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
#if !MAINWINDOW_ENABLE_UNDO
delete ui->actionUndo;
#endif
ui->optionsWidget->setVisible(ui->optionsCheckBox->isChecked());
setWindowTitle(APP_NAME);
playerSelector = new PlayerSelector(&tileFactory, this);
for (int i = 1; i <= MAX_PLAYERS; ++i)
{
QLabel * numberLabel = new QLabel(QString::number(i));
ui->ngPlayerLayout->addWidget(numberLabel, i, 0);
QComboBox * colorBox = new QComboBox();
for (uint j = 0; j < colors.size(); ++j)
{
colorBox->addItem(colorNames[j]);
QPixmap px(32, 32);
QPainter painter(&px);
painter.fillRect(px.rect(), colors[j]);
painter.drawRect(0, 0, px.width() - 1, px.height() - 1);
colorBox->setItemIcon(j, QIcon(px));
}
colorBox->setCurrentIndex(i-1);
ui->ngPlayerLayout->addWidget(colorBox, i, 1);
connect(colorBox, SIGNAL(currentIndexChanged(int)), this, SLOT(colorBoxChanged(int)));
QComboBox * typeBox = new QComboBox();
typeBox->addItems(QStringList{tr("", "player selection: no player"), tr("Player"), tr("Computer")});
ui->ngPlayerLayout->addWidget(typeBox, i, 2);
connect(typeBox, SIGNAL(currentIndexChanged(int)), this, SLOT(typeBoxChanged(int)));
QLineEdit * nameEdit = new QLineEdit();
ui->ngPlayerLayout->addWidget(nameEdit, i, 3);
ngPlayerEdits[i-1] = NgPlayerEdit{colorBox, typeBox, nameEdit};
}
auto actionGroup = new QActionGroup(this);
actionGroup->addAction(ui->actionRandom_Tiles);
actionGroup->addAction(ui->actionChoose_Tiles);
boardUi = new BoardGraphicsScene(&tileFactory, &imgFactory, ui->boardView);
game = new Game(this, true);
game->addView(this);
gameThread = new GameThread(game, this);
boardUi->setGame(game);
ui->boardView->setScene(boardUi);
connect(boardUi, SIGNAL(sceneRectChanged(QRectF)), this, SLOT(recenter(QRectF)));
connect(this, SIGNAL(gameEvent(QString)), this, SLOT(displayGameEvent(QString)));
connect(this, SIGNAL(gameEventPop()), this, SLOT(displayGameEventPop()));
readSettings();
game->addWatchingPlayer(this);
}
示例5: updateTable
//.........这里部分代码省略.........
//average line size
m_averageLineSize = static_cast<double>(totalChars) / lineCount;
unsigned approximateTotalLineCount = static_cast<unsigned>(file.size() / m_averageLineSize);
//we add a type selector for each column
QStringList propsText;
{
propsText.reserve(ASCII_OPEN_DLG_TYPES_COUNT);
for (unsigned i = 0; i < ASCII_OPEN_DLG_TYPES_COUNT; i++)
{
propsText << QString(ASCII_OPEN_DLG_TYPES_NAMES[i]);
}
}
//remove unnecessary columns
{
while (columnsCount < m_columnsCount)
m_ui->tableWidget->removeColumn(--m_columnsCount);
if (m_columnType.size() > columnsCount)
m_columnType.resize(columnsCount, UNKNOWN);
for (unsigned i = lineCount + 1; i <= DISPLAYED_LINES; ++i)
m_ui->tableWidget->removeRow(i);
}
//setup table and widgets
{
//Icons
static const QIcon xIcon (QString::fromUtf8(":/CC/images/typeXCoordinate.png"));
static const QIcon yIcon (QString::fromUtf8(":/CC/images/typeYCoordinate.png"));
static const QIcon zIcon (QString::fromUtf8(":/CC/images/typeZCoordinate.png"));
static const QIcon NormIcon (QString::fromUtf8(":/CC/images/typeNormal.png"));
static const QIcon RGBIcon (QString::fromUtf8(":/CC/images/typeRgbCcolor.png"));
static const QIcon GreyIcon (QString::fromUtf8(":/CC/images/typeGrayColor.png"));
static const QIcon ScalarIcon (QString::fromUtf8(":/CC/images/typeSF.png"));
static const QIcon LabelIcon (QString::fromUtf8(":/CC/images/dbLabelSymbol.png"));
int columnWidth = (m_ui->tableWidget->width() * 9) / (columnsCount * 10);
columnWidth = std::max(columnWidth, 80);
for (unsigned i = 0; i < columnsCount; i++)
{
QComboBox* columnHeaderWidget = static_cast<QComboBox*>(m_ui->tableWidget->cellWidget(0, i));
QComboBox* _columnHeader = columnHeaderWidget;
if (!columnHeaderWidget)
{
columnHeaderWidget = new QComboBox();
columnHeaderWidget->addItems(propsText);
columnHeaderWidget->setMaxVisibleItems(ASCII_OPEN_DLG_TYPES_COUNT);
columnHeaderWidget->setCurrentIndex(0);
columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_X, xIcon);
columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_Y, yIcon);
columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_Z, zIcon);
columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_NX, NormIcon);
columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_NY, NormIcon);
columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_NZ, NormIcon);
columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_R, RGBIcon);
columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_G, RGBIcon);
columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_B, RGBIcon);
columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_Rf, RGBIcon);
columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_Gf, RGBIcon);
columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_Bf, RGBIcon);
columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_Grey, GreyIcon);
columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_RGB32i, RGBIcon);
columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_RGB32f, RGBIcon);
columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_Label, LabelIcon);
columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_Scalar, ScalarIcon);
connect(columnHeaderWidget, SIGNAL(currentIndexChanged(int)), this, SLOT(columnsTypeHasChanged(int)));
}
while (m_columnType.size() <= static_cast<size_t>(i))
m_columnType.push_back(UNKNOWN);
assert(m_columnType.size() >= static_cast<size_t>(i));
if (!_columnHeader)
m_ui->tableWidget->setCellWidget(0, i, columnHeaderWidget);
m_ui->tableWidget->setColumnWidth(i, columnWidth);
//a non-numerical column can't be valid
if (!valueIsNumber[i])
m_columnType[i] = TEXT;
else
// we must do this to ensure we can get a correct result.
// Otherwise, we may fail in such situations:
//
// FILE:
// Line1 : $ gps file
// Line2 : $ id name x y z
// Line3 : 500
// Line4 : 0 0001.JPG 753811.417453 4307200.381522 1957.803955
// Linex : ......
// Line503 : 499 0500.JPG 753630.672714 4307195.433217 1957.803955
//
// Description:
// once we open the file, we will get a %m_columnType with 5 values of "TEXT"
// then if we choose to skip the 3 first lines, we get a %valueIsNumber with 5 "true"
// but the %m_columnType is still with 5 values of "TEXT" which leads to the failure!
m_columnType[i] = UNKNOWN;
}
}
示例6: updateTable
//.........这里部分代码省略.........
++n;
if (n != 0)
m_headerLine.remove(0,n);
m_ui->headerLabel->setText(QString("Header: ")+m_headerLine);
m_ui->headerLabel->setVisible(true);
}
else
{
m_ui->headerLabel->setVisible(false);
}
m_ui->commentLinesSkippedLabel->setVisible(commentLines != 0);
if (commentLines)
m_ui->commentLinesSkippedLabel->setText(QString("+ %1 comment line(s) skipped").arg(commentLines));
if (lineCount == 0 || columnsCount == 0)
{
m_averageLineSize = -1.0;
m_ui->tableWidget->clear();
m_columnsValidty.clear();
return;
}
//average line size
m_averageLineSize = static_cast<double>(totalChars)/lineCount;
//we add a type selector for each column
QStringList propsText;
{
for (unsigned i=0; i<ASCII_OPEN_DLG_TYPES_NUMBER; i++)
propsText << QString(ASCII_OPEN_DLG_TYPES_NAMES[i]);
}
//remove unnecessary columns
{
while (columnsCount < m_columnsCount)
m_ui->tableWidget->removeColumn(--m_columnsCount);
if (m_columnsValidty.size() > columnsCount)
m_columnsValidty.resize(columnsCount);
for (unsigned i=lineCount+1; i<=DISPLAYED_LINES; ++i)
m_ui->tableWidget->removeRow(i);
}
//setup table and widgets
{
//Icons
static const QIcon xIcon (QString::fromUtf8(":/CC/images/typeXCoordinate.png"));
static const QIcon yIcon (QString::fromUtf8(":/CC/images/typeYCoordinate.png"));
static const QIcon zIcon (QString::fromUtf8(":/CC/images/typeZCoordinate.png"));
static const QIcon NormIcon (QString::fromUtf8(":/CC/images/typeNormal.png"));
static const QIcon RGBIcon (QString::fromUtf8(":/CC/images/typeRgbCcolor.png"));
static const QIcon GreyIcon (QString::fromUtf8(":/CC/images/typeGrayColor.png"));
static const QIcon ScalarIcon (QString::fromUtf8(":/CC/images/typeSF.png"));
int columnWidth = (m_ui->tableWidget->width()*9) / (columnsCount*10);
columnWidth = std::max(columnWidth,80);
for (unsigned i=0; i<columnsCount; i++)
{
QComboBox* columnHeaderWidget = static_cast<QComboBox*>(m_ui->tableWidget->cellWidget(0,i));
QComboBox* _columnHeader = columnHeaderWidget;
if (!columnHeaderWidget)
{
columnHeaderWidget = new QComboBox();
columnHeaderWidget->addItems(propsText);
columnHeaderWidget->setMaxVisibleItems(ASCII_OPEN_DLG_TYPES_NUMBER);
columnHeaderWidget->setCurrentIndex(0);
columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_X,xIcon);
columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_Y,yIcon);
columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_Z,zIcon);
columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_NX,NormIcon);
columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_NY,NormIcon);
columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_NZ,NormIcon);
columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_R,RGBIcon);
columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_G,RGBIcon);
columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_B,RGBIcon);
columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_Rf,RGBIcon);
columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_Gf,RGBIcon);
columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_Bf,RGBIcon);
columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_Grey,GreyIcon);
columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_Scalar,ScalarIcon);
columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_RGB32i,RGBIcon);
columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_RGB32f,RGBIcon);
connect(columnHeaderWidget, SIGNAL(currentIndexChanged(int)), this, SLOT(columnsTypeHasChanged(int)));
}
while (m_columnsValidty.size() <= static_cast<size_t>(i))
m_columnsValidty.push_back(false);
assert(m_columnsValidty.size() >= static_cast<size_t>(i));
if (!_columnHeader)
m_ui->tableWidget->setCellWidget(0,i,columnHeaderWidget);
m_ui->tableWidget->setColumnWidth(i,columnWidth);
//a non-numerical column can't be valid
if (!valueIsNumber[i])
m_columnsValidty[i] = false;
}
}