本文整理汇总了C++中QTreeWidgetItem::setSizeHint方法的典型用法代码示例。如果您正苦于以下问题:C++ QTreeWidgetItem::setSizeHint方法的具体用法?C++ QTreeWidgetItem::setSizeHint怎么用?C++ QTreeWidgetItem::setSizeHint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTreeWidgetItem
的用法示例。
在下文中一共展示了QTreeWidgetItem::setSizeHint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fillPartialArchiveItem
void ArchiveList::fillPartialArchiveItem(PartialArchive *a, QTreeWidgetItem *item)
{
QTreeWidgetItem *subItem = new QTreeWidgetItem(item);
QPushButton *pauseButton = new QPushButton();
pauseButton->setText(a->isDownloading() ? tr("Pause") : tr("Continue"));
connect(pauseButton, SIGNAL(clicked()), a, SLOT(togglePauseDownload()));
downloadPausedMapper->setMapping(a, pauseButton);
downloadStartedMapper->setMapping(a, pauseButton);
connect(a, SIGNAL(downloadStarted()), downloadStartedMapper, SLOT(map()));
connect(a, SIGNAL(downloadPaused()), downloadPausedMapper, SLOT(map()));
int pbarColumn;
if (compactLayout) {
pbarColumn = 1;
subItem->setSizeHint(1, pauseButton->sizeHint());
setItemWidget(subItem, 1, pauseButton);
QPushButton *detailsButton = new QPushButton(tr("Details"));
showDetailsMapper->setMapping(detailsButton, a);
connect(detailsButton, SIGNAL(clicked()), showDetailsMapper, SLOT(map()));
subItem->setSizeHint(0, detailsButton->sizeHint());
setItemWidget(subItem, 0, detailsButton);
} else {
pbarColumn = 2;
item->setSizeHint(3, pauseButton->sizeHint());
setItemWidget(item, 3, pauseButton);
item->setText(1, a->getSizeMB());
QLabel *peerInfo = new QLabel();
subItem->setSizeHint(1, peerInfo->sizeHint());
setItemWidget(subItem, 1, peerInfo);
connect(a, SIGNAL(peerInfoUpdated(QString)), peerInfo, SLOT(setText(QString)));
QLabel *speedText = new QLabel();
subItem->setSizeHint(2, speedText->sizeHint());
setItemWidget(subItem, 2, speedText);
connect(a, SIGNAL(speedTextUpdated(QString)), speedText, SLOT(setText(QString)));
QLabel *statusText = new QLabel();
subItem->setSizeHint(3, statusText->sizeHint());
setItemWidget(subItem, 3, statusText);
connect(a, SIGNAL(statusTextUpdated(QString)), statusText, SLOT(setText(QString)));
}
QProgressBar *pbar = new QProgressBar();
pbar->setMinimum(0);
pbar->setMaximum(100);
item->setSizeHint(pbarColumn, pbar->sizeHint());
setItemWidget(item, pbarColumn, pbar);
connect(a, SIGNAL(progressUpdated(int)), pbar, SLOT(setValue(int)));
a->emitStatusEvents();
}
示例2: importCustomToolbars
void DlgCustomToolbars::importCustomToolbars(const QByteArray& name)
{
ParameterGrp::handle hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->GetGroup("Workbench");
const char* subgroup = (type == Toolbar ? "Toolbar" : "Toolboxbar");
if (!hGrp->HasGroup(name.constData()))
return;
hGrp = hGrp->GetGroup(name.constData());
if (!hGrp->HasGroup(subgroup))
return;
hGrp = hGrp->GetGroup(subgroup);
std::string separator = "Separator";
std::vector<Base::Reference<ParameterGrp> > hGrps = hGrp->GetGroups();
CommandManager& rMgr = Application::Instance->commandManager();
for (std::vector<Base::Reference<ParameterGrp> >::iterator it = hGrps.begin(); it != hGrps.end(); ++it) {
// create a toplevel item
QTreeWidgetItem* toplevel = new QTreeWidgetItem(toolbarTreeWidget);
bool active = (*it)->GetBool("Active", true);
toplevel->setCheckState(0, (active ? Qt::Checked : Qt::Unchecked));
// get the elements of the subgroups
std::vector<std::pair<std::string,std::string> > items = (*it)->GetASCIIMap();
for (std::vector<std::pair<std::string,std::string> >::iterator it2 = items.begin(); it2 != items.end(); ++it2) {
// since we have stored the separators to the user parameters as (key, pair) we had to
// make sure to use a unique key because otherwise we cannot store more than
// one.
if (it2->first.substr(0, separator.size()) == separator) {
QTreeWidgetItem* item = new QTreeWidgetItem(toplevel);
item->setText(0, tr("<Separator>"));
item->setData(0, Qt::UserRole, QByteArray("Separator"));
item->setSizeHint(0, QSize(32, 32));
}
else if (it2->first == "Name") {
QString toolbarName = QString::fromUtf8(it2->second.c_str());
toplevel->setText(0, toolbarName);
}
else {
Command* pCmd = rMgr.getCommandByName(it2->first.c_str());
if (pCmd) {
// command name
QTreeWidgetItem* item = new QTreeWidgetItem(toplevel);
item->setText(0, qApp->translate(pCmd->className(), pCmd->getMenuText()));
item->setData(0, Qt::UserRole, QByteArray(it2->first.c_str()));
if (pCmd->getPixmap())
item->setIcon(0, BitmapFactory().iconFromTheme(pCmd->getPixmap()));
item->setSizeHint(0, QSize(32, 32));
}
}
}
}
}
示例3: QWidget
LxQtThemeConfig::LxQtThemeConfig(LxQt::Settings *settings, QWidget *parent) :
QWidget(parent),
ui(new Ui::LxQtThemeConfig),
mSettings(settings)
{
ui->setupUi(this);
connect(ui->lxqtThemeList, SIGNAL(itemClicked(QTreeWidgetItem*,int)),
this, SLOT(lxqtThemeSelected(QTreeWidgetItem*,int)));
QList<LxQt::LxQtTheme> themes = LxQt::LxQtTheme::allThemes();
foreach(LxQt::LxQtTheme theme, themes)
{
QString themeName = theme.name();
themeName[0] = themeName[0].toTitleCase();
QTreeWidgetItem *item = new QTreeWidgetItem(QStringList(themeName));
if (!theme.previewImage().isEmpty())
{
item->setIcon(0, QIcon(theme.previewImage()));
}
item->setSizeHint(0, QSize(42,42)); // make icons non-cropped
item->setData(0, Qt::UserRole, theme.name());
ui->lxqtThemeList->addTopLevelItem(item);
}
示例4: onModifyMacroAction
void DlgCustomKeyboardImp::onModifyMacroAction(const QByteArray& macro)
{
QVariant data = categoryBox->itemData(categoryBox->currentIndex(), Qt::UserRole);
QString group = data.toString();
if (group == QLatin1String("Macros"))
{
CommandManager & cCmdMgr = Application::Instance->commandManager();
Command* pCmd = cCmdMgr.getCommandByName(macro);
for (int i=0; i<commandTreeWidget->topLevelItemCount(); i++) {
QTreeWidgetItem* item = commandTreeWidget->topLevelItem(i);
QByteArray command = item->data(1, Qt::UserRole).toByteArray();
if (command == macro) {
item->setText(1, QString::fromUtf8(pCmd->getMenuText()));
item->setToolTip(1, QString::fromUtf8(pCmd->getToolTipText()));
item->setData(1, Qt::UserRole, macro);
item->setSizeHint(0, QSize(32, 32));
item->setBackgroundColor(0, Qt::lightGray);
if (pCmd->getPixmap())
item->setIcon(0, BitmapFactory().iconFromTheme(pCmd->getPixmap()));
if (commandTreeWidget->isItemSelected(item))
textLabelDescription->setText(item->toolTip(1));
break;
}
}
}
}
示例5: startDownload
void MainWindow::startDownload()
{
QTreeWidgetItem* tmpItem = new QTreeWidgetItem(QStringList() << currentVideo->getName() << currentVideo->title() << ui.downloadComboFormat->currentText());
tmpItem->setSizeHint(0, QSize(16, 24));
currentVideo->setTreeItem(tmpItem);
currentVideo->setQuality(ui.downloadComboQuality->currentIndex());
currentVideo->setConverter(cg->formats.at(ui.downloadComboFormat->currentIndex())._converter->createNewInstance(),cg->formats.at(ui.downloadComboFormat->currentIndex())._mode);
QString target;
if (cg->settings.value("NeverAskForPath", false).toBool() == false)
{
target = QFileDialog::getSaveFileName(this, tr("Select Target"), cg->settings.value("savedPath", QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)).toString() +"/" + currentVideo->getSaveTitle());
}
else
{
target = cg->settings.value("savedPath", QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)).toString() +"/"+currentVideo->getSaveTitle();
}
if (!target.isEmpty())
{
if (cg->settings.value("saveLastPath", true) == true)
{
QString targetDir = target;
targetDir.remove(targetDir.split("/", QString::SkipEmptyParts).last()).replace(QRegExp("/+"), "/");
ui.settingsSavedPath->setText(targetDir);
}
currentVideo->setTargetPath(target);
if (cg->settings.value("UseMetadata", false).toBool() == true)
{
if (ui.downloadComboFormat->currentIndex() == 4 || ui.downloadComboFormat->currentIndex() == 5)
{
metadataDialog = new QDialog;
mdui.setupUi(metadataDialog);
mdui.title->setText(currentVideo->title());
metadataDialog->setModal(true);
metadataDialog->exec();
currentVideo->setMetaTitle(mdui.title->text());
currentVideo->setMetaArtist(mdui.artist->text());
delete metadataDialog;
}
}
cg->addDownload(currentVideo);
ui.downloadTree->insertTopLevelItem(0, tmpItem);
currentVideo->_progressBar = new QProgressBar();
currentVideo->_progressBar->setValue(0);
currentVideo->_progressBar->setMaximum(1);
ui.downloadTree->setItemWidget(tmpItem, 3, currentVideo->_progressBar);
((QProgressBar*) ui.downloadTree->itemWidget(tmpItem, 3))->setMaximum(100);
connect(currentVideo, SIGNAL(progressChanged(int,int)),ui.downloadTree, SLOT(update()));
connect(currentVideo, SIGNAL(downloadFinished()), currentVideo, SLOT(startConvert()));
connect(currentVideo, SIGNAL(conversionFinished(video*)), this, SLOT(handleFinishedConversion(video*)));
currentVideo = NULL;
ui.downloadLineEdit->clear();
}
}
示例6: resizeLastHint
void AlbumList::resizeLastHint()
{
int counts = childCount();
QTreeWidgetItem* item = child(counts-1);
if( !item ) return;
// qDebug() << counts;
// 当前行数小于8行,则需要增加高度
if( 8 - counts > 1 )
{
item->setSizeHint( 0, QSize(1, 16*(8-counts)) );
}
else
{
int h = item->sizeHint(0).height();
if( h > 16 )
item->setSizeHint( 0, QSize(1, h/(counts-8)) );
}
}
示例7: slotCheckPrograms
void Wizard::slotCheckPrograms()
{
m_check.programList->setColumnCount(2);
m_check.programList->setRootIsDecorated(false);
m_check.programList->setHeaderHidden(true);
QSize itemSize(20, fontMetrics().height() * 2.5);
m_check.programList->setColumnWidth(0, 30);
m_check.programList->setIconSize(QSize(24, 24));
QTreeWidgetItem *item = new QTreeWidgetItem(m_check.programList, QStringList() << QString() << i18n("FFmpeg & ffplay"));
item->setData(1, Qt::UserRole, i18n("Required for webcam capture"));
item->setSizeHint(0, itemSize);
QString exepath = KStandardDirs::findExe("ffmpeg");
if (exepath.isEmpty()) item->setIcon(0, m_badIcon);
else if (KStandardDirs::findExe("ffplay").isEmpty()) item->setIcon(0, m_badIcon);
else item->setIcon(0, m_okIcon);
item = new QTreeWidgetItem(m_check.programList, QStringList() << QString() << i18n("Recordmydesktop"));
item->setData(1, Qt::UserRole, i18n("Required for screen capture"));
item->setSizeHint(0, itemSize);
if (KStandardDirs::findExe("recordmydesktop").isEmpty()) item->setIcon(0, m_badIcon);
else item->setIcon(0, m_okIcon);
item = new QTreeWidgetItem(m_check.programList, QStringList() << QString() << i18n("Dvgrab"));
item->setData(1, Qt::UserRole, i18n("Required for firewire capture"));
item->setSizeHint(0, itemSize);
if (KStandardDirs::findExe("dvgrab").isEmpty()) item->setIcon(0, m_badIcon);
else item->setIcon(0, m_okIcon);
item = new QTreeWidgetItem(m_check.programList, QStringList() << QString() << i18n("Dvdauthor"));
item->setData(1, Qt::UserRole, i18n("Required for creation of DVD"));
item->setSizeHint(0, itemSize);
if (KStandardDirs::findExe("dvdauthor").isEmpty()) item->setIcon(0, m_badIcon);
else item->setIcon(0, m_okIcon);
item = new QTreeWidgetItem(m_check.programList, QStringList() << QString() << i18n("Mkisofs"));
item->setData(1, Qt::UserRole, i18n("Required for creation of DVD ISO images"));
item->setSizeHint(0, itemSize);
if (KStandardDirs::findExe("mkisofs").isEmpty()) item->setIcon(0, m_badIcon);
else item->setIcon(0, m_okIcon);
}
示例8: scanBlocks
/**
* @brief 遍历所有的Block
* @param dirPath 目录路径
*/
void WidgetMain::scanBlocks(const QString &dirPath, QTreeWidgetItem *parentItem, QMenu *parentMenu)
{
QDir dir(dirPath);
DataStruct data;
{
dir.setFilter(QDir::Files);
QStringList tmp;
foreach (const QString &fileName, dir.entryList())
{
QString filePath = dirPath + "/" + fileName;
//啦拉拉在这里读取数据
QFileInfo infor(filePath);
if(0 == infor.size())
{
continue;
}
data = GetBlockData::getBlockData(filePath);
Translate::map_fileName_filePath_.insert(infor.baseName(), filePath);
if(!data.isEmpty())
{
hash_blockPath_blockData_.insert(data.ui.name, data);//创建的时候需要的是模块的文件名
map_moduleName_moduleTag_.insert(data.ui.name, data.ui.tag);//ui.fileName是模块的显示的名字...
tmp.append(data.ui.name);
}
//处理menu相关
QAction *pAction = parentMenu->addAction(infor.baseName());
connect(pAction, SIGNAL(triggered()), this, SLOT(slotActionTriggered()));
}
map_dirPath_blockNames_.insert(dirPath, tmp);
}
{
dir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
foreach (const QString &dirName, dir.entryList())
{
QString childDirPath = dirPath + "/" + dirName;
//对treeWidget的处理
QTreeWidgetItem *pChildItem = new QTreeWidgetItem(parentItem, QStringList(QString(dirName)));
//QTreeWidgetItem *pChildItem = new ListWidget(parentItem, QStringList(QString(dirName)));
pChildItem->setData(0,Qt::UserRole+1,dirPath);
pChildItem->setSizeHint(0, QSize(100, 20));
parentItem->addChild(pChildItem);
map_treeWidgetItemPointer_pageIndex_.insert(pChildItem, pageIndex_++);
//memu
QMenu *pMenu = parentMenu->addMenu(dirName);
scanBlocks(childDirPath, pChildItem, pMenu);
}
}
}
示例9: on_categoryBox_activated
void DlgCustomToolbars::on_categoryBox_activated(int index)
{
QVariant data = categoryBox->itemData(index, Qt::UserRole);
QString group = data.toString();
commandTreeWidget->clear();
CommandManager & cCmdMgr = Application::Instance->commandManager();
std::vector<Command*> aCmds = cCmdMgr.getGroupCommands(group.toLatin1());
// Create a separator item
QTreeWidgetItem* sepitem = new QTreeWidgetItem(commandTreeWidget);
sepitem->setText(1, tr("<Separator>"));
sepitem->setData(1, Qt::UserRole, QByteArray("Separator"));
sepitem->setSizeHint(0, QSize(32, 32));
if (group == QLatin1String("Macros")) {
for (std::vector<Command*>::iterator it = aCmds.begin(); it != aCmds.end(); ++it) {
QTreeWidgetItem* item = new QTreeWidgetItem(commandTreeWidget);
item->setText(1, QString::fromUtf8((*it)->getMenuText()));
item->setToolTip(1, QString::fromUtf8((*it)->getToolTipText()));
item->setData(1, Qt::UserRole, QByteArray((*it)->getName()));
item->setSizeHint(0, QSize(32, 32));
if ((*it)->getPixmap())
item->setIcon(0, BitmapFactory().iconFromTheme((*it)->getPixmap()));
}
}
else {
for (std::vector<Command*>::iterator it = aCmds.begin(); it != aCmds.end(); ++it) {
QTreeWidgetItem* item = new QTreeWidgetItem(commandTreeWidget);
item->setText(1, qApp->translate((*it)->className(), (*it)->getMenuText()));
item->setToolTip(1, qApp->translate((*it)->className(), (*it)->getToolTipText()));
item->setData(1, Qt::UserRole, QByteArray((*it)->getName()));
item->setSizeHint(0, QSize(32, 32));
if ((*it)->getPixmap())
item->setIcon(0, BitmapFactory().iconFromTheme((*it)->getPixmap()));
}
}
}
示例10: onGroupActivated
/** Shows all commands of this category */
void DlgCustomCommandsImp::onGroupActivated(QTreeWidgetItem* item)
{
if (!item)
return;
QVariant data = item->data(0, Qt::UserRole);
QString group = data.toString();
commandTreeWidget->clear();
CommandManager & cCmdMgr = Application::Instance->commandManager();
std::vector<Command*> aCmds = cCmdMgr.getGroupCommands(group.toLatin1());
if (group == QLatin1String("Macros")) {
for (std::vector<Command*>::iterator it = aCmds.begin(); it != aCmds.end(); ++it) {
QTreeWidgetItem* item = new QTreeWidgetItem(commandTreeWidget);
item->setText(1, QString::fromUtf8((*it)->getMenuText()));
item->setToolTip(1, QString::fromUtf8((*it)->getToolTipText()));
item->setData(1, Qt::UserRole, QByteArray((*it)->getName()));
item->setSizeHint(0, QSize(32, 32));
if ((*it)->getPixmap())
item->setIcon(0, BitmapFactory().iconFromTheme((*it)->getPixmap()));
}
}
else {
for (std::vector<Command*>::iterator it = aCmds.begin(); it != aCmds.end(); ++it) {
QTreeWidgetItem* item = new QTreeWidgetItem(commandTreeWidget);
item->setText(1, qApp->translate((*it)->className(), (*it)->getMenuText()));
item->setToolTip(1, qApp->translate((*it)->className(), (*it)->getToolTipText()));
item->setData(1, Qt::UserRole, QByteArray((*it)->getName()));
item->setSizeHint(0, QSize(32, 32));
if ((*it)->getPixmap())
item->setIcon(0, BitmapFactory().iconFromTheme((*it)->getPixmap()));
}
}
textLabel->setText(QString());
}
示例11: addDefaultHit
void Sak::addDefaultHit()
{
QTreeWidgetItem* i = new QTreeWidgetItem;
Task::Hit p(QDateTime::currentDateTime(), 0);
i->setText(0, p.timestamp.toString(DATETIMEFORMAT));
i->setText(1, m_editedTasks.begin().key());
i->setIcon(1, m_editedTasks.begin().value().icon);
i->setSizeHint(0, QSize(32, 32));
i->setText(3, QString("%1").arg(p.duration));
i->setFlags(i->flags() | Qt::ItemIsEditable);
hitsList->addTopLevelItem( i );
m_changedHit=true;
m_editedTasks[i->text(1)].hits[i->text(2)] << p;
i->setData(1, Qt::UserRole, qVariantFromValue(HitElement(&m_editedTasks[i->text(1)], i->text(2), p.timestamp, p.duration)));
}
示例12: onAddMacroAction
void DlgCustomKeyboardImp::onAddMacroAction(const QByteArray& macro)
{
QVariant data = categoryBox->itemData(categoryBox->currentIndex(), Qt::UserRole);
QString group = data.toString();
if (group == QLatin1String("Macros"))
{
CommandManager & cCmdMgr = Application::Instance->commandManager();
Command* pCmd = cCmdMgr.getCommandByName(macro);
QTreeWidgetItem* item = new QTreeWidgetItem(commandTreeWidget);
item->setText(1, QString::fromUtf8(pCmd->getMenuText()));
item->setToolTip(1, QString::fromUtf8(pCmd->getToolTipText()));
item->setData(1, Qt::UserRole, macro);
item->setSizeHint(0, QSize(32, 32));
if (pCmd->getPixmap())
item->setIcon(0, BitmapFactory().iconFromTheme(pCmd->getPixmap()));
}
}
示例13: buildLog
void DownloadLogImpl::buildLog(QList<LogEntry> logEntries, VideoInformation *videoInformation)
{
for (int n = 0; n < logEntries.count(); n++)
{
QTreeWidgetItem *item = new LogTreeWidgetItem(lsvLog);
item->setText(0, logEntries.at(n).dateTime.toString());
item->setText(1, logEntries.at(n).title);
item->setText(2, logEntries.at(n).URL);
item->setIcon(0, QIcon(videoInformation->getHostImage(logEntries.at(n).URL)));
item->setSizeHint(0, QSize(18,18));
item->setData(0, Qt::UserRole, logEntries.at(n).dateTime);
}
// sort list
lsvLog->sortItems(0, Qt::AscendingOrder);
}
示例14: fillUpdates
void UpdateCenterImpl::fillUpdates()
{
for (int n = 0; n < updates->getUpdatesCount(); n++)
{
QTreeWidgetItem *item = new QTreeWidgetItem(lsvUpdates);
item->setTextAlignment(1, Qt::AlignHCenter | Qt::AlignVCenter);
item->setTextAlignment(2, Qt::AlignRight | Qt::AlignVCenter);
item->setTextAlignment(3, Qt::AlignHCenter | Qt::AlignVCenter);
item->setText(0, updates->getUpdateItem(n)->getCaption());
item->setText(1, updates->getUpdateItem(n)->getVersion());
item->setText(2, fileSizeToString(updates->getUpdateItem(n)->getSize()));
item->setText(3, "-");
item->setSizeHint(0, QSize(18,18));
item->setCheckState(0, Qt::Checked);
}
}
示例15: slt_showInboxMessages
void JBlockerMainWindow::slt_showInboxMessages()
{
qDebug() << "+ " << __PRETTY_FUNCTION__;
p_inboxW->clear();
/* Show messages classified based on sender's name */
p_nameToMessageHash = p_messageCore->getNameInfoHash();
/* Get name list */
QList<QString> nameList = p_nameToMessageHash.keys();
/* Get current account message type */
QMessage::TypeFlags accountType = p_messageCore->getCurrentAccountType();
/* Put classified infos into inbox tree widget */
for(int i=0; i<nameList.count(); i++)
{
QString name = nameList.at(i);
QStringList rootItemString;
/* Set the root element for each sender */
/* Check message type */
rootItemString << (accountType == QMessage::Sms ? p_messageCore->getContactName(name) : name) << QString("%1 message").arg(p_messageCore->messageCount(name));
QTreeWidgetItem* parentItem = new QTreeWidgetItem(rootItemString);
parentItem->setData(0, MessageIdRole, name);
p_inboxW->addTopLevelItem(parentItem);
/* Set children items for each sender */
QList<QMessage>* messageList = p_messageCore->getMessageList(name);
for(int j=0; j<messageList->count(); j++)
{
QMessage msg = messageList->at(j);
QStringList childItemString;
QString subject = QString::fromUtf8(msg.subject().toAscii());
childItemString << subject << msg.date().toLocalTime().toString(QString("hh:mm:ss dd.MM.yyyy"));
QTreeWidgetItem* childItem = new QTreeWidgetItem(childItemString);
/* Set messageID as the DATA of each children items */
childItem->setData(0, MessageIdRole, msg.id().toString());
/* Set the size hint of children */
childItem->setSizeHint(0, p_inboxW->headerItem()->sizeHint(0));
p_inboxW->topLevelItem(i)->addChild(childItem);
}
}
}