本文整理汇总了C++中QListWidgetItem::setSizeHint方法的典型用法代码示例。如果您正苦于以下问题:C++ QListWidgetItem::setSizeHint方法的具体用法?C++ QListWidgetItem::setSizeHint怎么用?C++ QListWidgetItem::setSizeHint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QListWidgetItem
的用法示例。
在下文中一共展示了QListWidgetItem::setSizeHint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fm
void
SettingsDialog::createIcons()
{
/// Not fun but QListWidget sucks. Do our max-width calculation manually
/// so the icons arre lined up.
// Resolvers is the longest string... in english. fml.
int maxlen = 0;
QFontMetrics fm( font() );
QListWidgetItem *accountsButton = new QListWidgetItem( ui->listWidget );
accountsButton->setIcon( QIcon( RESPATH "images/account-settings.png" ) );
accountsButton->setText( tr( "Accounts" ) );
accountsButton->setTextAlignment( Qt::AlignHCenter );
accountsButton->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
maxlen = fm.width( accountsButton->text() );
QListWidgetItem *musicButton = new QListWidgetItem( ui->listWidget );
musicButton->setIcon( QIcon( RESPATH "images/music-settings.png" ) );
musicButton->setText( tr( "Music" ) );
musicButton->setTextAlignment( Qt::AlignHCenter );
musicButton->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
maxlen = qMax( fm.width( musicButton->text() ), maxlen );
QListWidgetItem *lastfmButton = new QListWidgetItem( ui->listWidget );
lastfmButton->setIcon( QIcon( RESPATH "images/lastfm-settings.png" ) );
lastfmButton->setText( tr( "Last.fm" ) );
lastfmButton->setTextAlignment( Qt::AlignHCenter );
lastfmButton->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
maxlen = qMax( fm.width( lastfmButton->text() ), maxlen );
QListWidgetItem *resolversButton = new QListWidgetItem( ui->listWidget );
resolversButton->setIcon( QIcon( RESPATH "images/resolvers-settings.png" ) );
resolversButton->setText( tr( "Resolvers" ) );
resolversButton->setTextAlignment( Qt::AlignHCenter );
resolversButton->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
maxlen = qMax( fm.width( resolversButton->text() ), maxlen );
QListWidgetItem *advancedButton = new QListWidgetItem( ui->listWidget );
advancedButton->setIcon( QIcon( RESPATH "images/advanced-settings.png" ) );
advancedButton->setText( tr( "Advanced" ) );
advancedButton->setTextAlignment( Qt::AlignHCenter );
advancedButton->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
maxlen = qMax( fm.width( advancedButton->text() ), maxlen );
maxlen += 15; // padding
accountsButton->setSizeHint( QSize( maxlen, 60 ) );
musicButton->setSizeHint( QSize( maxlen, 60 ) );
lastfmButton->setSizeHint( QSize( maxlen, 60 ) );
resolversButton->setSizeHint( QSize( maxlen, 60 ) );
advancedButton->setSizeHint( QSize( maxlen, 60 ) );
#ifndef Q_WS_MAC
// doesn't listen to sizehint...
ui->listWidget->setMaximumWidth( maxlen + 8 );
#endif
connect( ui->listWidget, SIGNAL( currentItemChanged( QListWidgetItem* ,QListWidgetItem* ) ), this, SLOT( changePage( QListWidgetItem*, QListWidgetItem* ) ) );
}
示例2: generalIcon
SettingsDialog::SettingsDialog(Application *app, QWidget *parent) :
QDialog(parent),
_ui(new Ui::SettingsDialog)
{
_ui->setupUi(this);
setObjectName("Settings"); // required as group for saveGeometry call
setWindowTitle(tr("%1 Settings").arg(Theme::instance()->appNameGUI()));
QIcon generalIcon(QLatin1String(":/mirall/resources/settings.png"));
QListWidgetItem *general = new QListWidgetItem(generalIcon, tr("General"), _ui->labelWidget);
general->setSizeHint(QSize(0, 32));
_ui->labelWidget->addItem(general);
GeneralSettings *generalSettings = new GeneralSettings;
_ui->stack->addWidget(generalSettings);
QIcon networkIcon(QLatin1String(":/mirall/resources/network.png"));
QListWidgetItem *network = new QListWidgetItem(networkIcon, tr("Network"), _ui->labelWidget);
network->setSizeHint(QSize(0, 32));
_ui->labelWidget->addItem(network);
NetworkSettings *networkSettings = new NetworkSettings;
_ui->stack->addWidget(networkSettings);
connect(networkSettings, SIGNAL(proxySettingsChanged()), app, SLOT(slotSetupProxy()));
connect(networkSettings, SIGNAL(proxySettingsChanged()), FolderMan::instance(), SLOT(slotScheduleAllFolders()));
//connect(generalSettings, SIGNAL(resizeToSizeHint()), SLOT(resizeToSizeHint()));
_accountSettings = new AccountSettings(this);
addAccount(tr("Account"), _accountSettings);
slotUpdateAccountState();
connect( app, SIGNAL(folderStateChanged(Folder*)), _accountSettings, SLOT(slotUpdateFolderState(Folder*)));
connect( app, SIGNAL(folderStateChanged(Folder*)), SLOT(slotUpdateAccountState()));
connect( _accountSettings, SIGNAL(addASync()), app, SLOT(slotFolderAdded()) );
connect( _accountSettings, SIGNAL(folderChanged()), app, SLOT(slotFoldersChanged()));
connect( _accountSettings, SIGNAL(openFolderAlias(const QString&)),
app, SLOT(slotFolderOpenAction(QString)));
connect( _accountSettings, SIGNAL(openProgressDialog()), app, SLOT(slotItemProgressDialog()));
connect( ProgressDispatcher::instance(), SIGNAL(progressInfo(QString, Progress::Info)),
_accountSettings, SLOT(slotSetProgress(QString, Progress::Info)) );
connect( ProgressDispatcher::instance(), SIGNAL(progressSyncProblem(QString,Progress::SyncProblem)),
_accountSettings, SLOT(slotProgressProblem(QString,Progress::SyncProblem)) );
_ui->labelWidget->setCurrentRow(_ui->labelWidget->row(general));
connect(_ui->labelWidget, SIGNAL(currentRowChanged(int)),
_ui->stack, SLOT(setCurrentIndex(int)));
QPushButton *closeButton = _ui->buttonBox->button(QDialogButtonBox::Close);
connect(closeButton, SIGNAL(pressed()), SLOT(accept()));
MirallConfigFile cfg;
cfg.restoreGeometry(this);
}
示例3: createControls
void ConfigComputerDialog::createControls()
{
lstView = new QListWidget(this);
pages = new QStackedWidget(this);
panMain = createMainWidget();
panSolver = createSolverWidget();
// List View
lstView->setCurrentRow(0);
lstView->setViewMode(QListView::IconMode);
lstView->setResizeMode(QListView::Adjust);
lstView->setMovement(QListView::Static);
lstView->setFlow(QListView::TopToBottom);
lstView->setIconSize(QSize(60, 60));
lstView->setMinimumWidth(135);
lstView->setMaximumWidth(135);
lstView->setMinimumHeight((45+fontMetrics().height()*4)*5);
connect(lstView, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
this, SLOT(doCurrentItemChanged(QListWidgetItem *, QListWidgetItem *)));
QSize sizeItem(131, 85);
// listView items
QListWidgetItem *itemMain = new QListWidgetItem(icon("options-main"), tr("Main"), lstView);
itemMain->setTextAlignment(Qt::AlignHCenter);
itemMain->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
itemMain->setSizeHint(sizeItem);
QListWidgetItem *itemSolver = new QListWidgetItem(icon("options-solver"), tr("Solver"), lstView);
itemSolver->setTextAlignment(Qt::AlignHCenter);
itemSolver->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
itemSolver->setSizeHint(sizeItem);
pages->addWidget(panMain);
pages->addWidget(panSolver);
QHBoxLayout *layoutHorizontal = new QHBoxLayout();
layoutHorizontal->addWidget(lstView);
layoutHorizontal->addWidget(pages);
// dialog buttons
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(doAccept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(doReject()));
QVBoxLayout *layout = new QVBoxLayout();
layout->addLayout(layoutHorizontal);
// layout->addStretch();
layout->addWidget(buttonBox);
setLayout(layout);
}
示例4: NowRun
void MainDialog::NowRun()
{
centerWidget(this);
this->show();
obj_this = this;
ui.setupUi(this);
QIcon accountIcon(QLatin1String(":rc/user.png"));
QListWidgetItem *account = new QListWidgetItem(accountIcon, "Account", ui.labelWidget);
account->setSizeHint(QSize(0, 32));
this->accountSettings = new AccountSettings(this);
ui.stack->addWidget(this->accountSettings);
QIcon syslogIcon(QLatin1String(":rc/loop_alt4.png"));
QListWidgetItem *syslog = new QListWidgetItem(syslogIcon, "Log Activity", ui.labelWidget);
syslog->setSizeHint(QSize(0, 32));
this->logSettings = new LogSettings;
ui.stack->addWidget(this->logSettings);
QIcon generalIcon(QLatin1String(":rc/cog.png"));
QListWidgetItem *general = new QListWidgetItem(generalIcon, "General", ui.labelWidget);
general->setSizeHint(QSize(0, 32));
this->generalSettings = new GeneralSettings(this);
ui.stack->addWidget(this->generalSettings);
ui.labelWidget->setCurrentRow(ui.labelWidget->row(account));
connect(ui.labelWidget, SIGNAL(currentRowChanged(int)),
ui.stack, SLOT(setCurrentIndex(int)));
connect(this->ui.exitButton, SIGNAL(clicked()), this, SLOT(slotExit()));
createTrayIcon();
setTrayIcon();
trayIcon->show();
agent_cfg = (struct agent_cfg*)calloc(1, sizeof(struct agent_cfg));
agent_cfg->ev.on_log = this->onLog;
if (agent_config_init(agent_cfg)) {
jlog(L_ERROR, "agent_config_init failed");
return;
}
if (agent_cfg->auto_connect != 0) {
emit this->generalSettings->slotCheckAutoConnect();
emit accountSettings->slotConnWaiting();
emit this->slotFireConnection();
}
}
示例5: ShowFolder
void AddMonitorWidget::ShowFolder(string path)
{
DIR *dirp=NULL;
dirp = opendir(path.c_str());
if(dirp == NULL)
return ;
struct dirent *dp;
listwidget->clear();
string name;
string par;
if(path != "/")
{
par = path + "/";
}
while(dp = readdir(dirp))
{
name = dp->d_name;
if(name != "." && name != ".." && name[0] == '.')
continue;
QListWidgetItem* item = new QListWidgetItem;
item->setSizeHint(QSize(0,40));
FileItem *itemWidget = new FileItem(this);
itemWidget->setItem(QString::fromStdString(name),QString::fromStdString(par));
if(name == ".")
listwidget->insertItem(0,item);
else if(name == "..")
listwidget->insertItem(1,item);
else
listwidget->addItem(item);
listwidget->setItemWidget(item,itemWidget);
connect(itemWidget,SIGNAL(SaveSig(int,QString)),this,SLOT(SaveSlot(int,QString)));
}
}
示例6: moveToDebugScreen
void KovanTestWindow::moveToDebugScreen()
{
ui->debugActiveLabel->setVisible(true);
ui->selectTestButton->setVisible(true);
ui->debugMode1->setVisible(false);
ui->debugMode2->setVisible(false);
ui->debugMode3->setVisible(false);
ui->testSelectionButton->setVisible(false);
ui->errorFailLabel->setVisible(false);
ui->errorLabel->setVisible(false);
ui->passLabel->setVisible(false);
ui->runSelectedTestsButton->setEnabled(false);
sequencePosition = 0;
engine->setDebug(true);
ui->startScreen->setVisible(false);
ui->debugScreen->setVisible(true);
QList<KovanTest *>tests = engine->allTests();
int i;
ui->testListWidget->clear();
for (i=0; i<tests.count(); i++) {
QListWidgetItem *item = new QListWidgetItem(*(tests.at(i)->testName()));
QVariant v = QVariant::fromValue<void*>(tests.at(i));
item->setData(Qt::UserRole, v);
item->setSizeHint(QSize(320,30));
ui->testListWidget->addItem(item);
connect(ui->testListWidget, SIGNAL(itemPressed(QListWidgetItem *)),
this, SLOT(debugItemPressed(QListWidgetItem *)));
}
ui->testListWidget->setDragDropMode(QAbstractItemView::NoDragDrop);
}
示例7: onSequenceChanged
void PluginFilterList::onSequenceChanged(GitlUpdateUIEvt &rcEvt)
{
// rebuild the filter list
int iVPos = verticalScrollBar()->value();
int iHPos = horizontalScrollBar()->value();
this->clear();
QStringList cFilterNames = rcEvt.getParameter("filter_names").toStringList();
QVector<bool> cFilterEnableStatus = rcEvt.getParameter("filter_status").value< QVector<bool> >();
for(int i = 0; i < cFilterNames.size(); i++)
{
QListWidgetItem* pcItem = new QListWidgetItem();
this->addItem(pcItem);
PluginFilterItem *pItemWidget = new PluginFilterItem(cFilterNames[i], cFilterEnableStatus[i]);
pcItem->setSizeHint(pItemWidget->sizeHint());
setItemWidget(pcItem, pItemWidget);
}
verticalScrollBar()->setValue(iVPos);
horizontalScrollBar()->setValue(iHPos);
}
示例8: dropEvent
void TimeTable::dropEvent(QDropEvent *event)
{
qDebug()<<dragEnabled();
if (event->mimeData()->hasFormat("timetable/item")) {
if(!dragEnabled()){
clear();
setDragEnabled(true);
}
//Reading tasklist item properties
QByteArray tmpd = event->mimeData()->data("timetable/item");
QDataStream ds(&tmpd, QIODevice::ReadOnly);
QColor color;
QString str;
QVariant duration;
ds >> color >> str >>duration;
QListWidgetItem *item;
item = new QListWidgetItem();
item->setBackgroundColor(color);
item->setText(str);
item->setSizeHint(QSize(0,0));
addItem(item);
item->setData(1,duration);
event->setDropAction(Qt::MoveAction);
event->accept();
refresh();
}
}
示例9: addEmptyItem
void TimeTable::addEmptyItem(){
QListWidgetItem* item = new QListWidgetItem();
item->setText("Drag&drop tasks here");
item->setSizeHint(QSize(size().width(),size().height()));
addItem(item);
setDragEnabled(false);
}
示例10: addFoodCatagory
void AdminWindow::addFoodCatagory(QString catagoryName, QImage imageName)
{
QString s = QString::number(rowCount++);
QWidget* w = new QWidget();
QVBoxLayout* layout = new QVBoxLayout();
w->setLayout(layout);
FoodCatagory* newCatagory = new FoodCatagory();
newCatagory->SetName(s);
newCatagory->SetCatagory(catagoryName);
newCatagory->SetImage(imageName);
foodCatagories.push_back(newCatagory);
layout->addWidget(newCatagory);
QListWidgetItem* item = new QListWidgetItem();
item->setSizeHint(QSize(0,60));
item->setText(s);
listWidget->setSpacing(2);
listWidget->addItem(item);
listWidget->setItemWidget(item, w);
ui->scrollArea_FoodCatagory->setWidget(listWidget);
}
示例11: addItemFromNet
//添加网络item
int PlaylistWindow::addItemFromNet(const QString &additem, const QString &link,int id, bool playNow)
{
QListWidgetItem *item = new QListWidgetItem(additem,listWidget);
int row = listWidget->row(item);
//添加索引字符
QString index = "";
if(row<9) {
index.append("0").append(QString::number(row+1,10).append(". "));
} else {
index = QString::number(row+1,10).append(". ");
}
item->setText(index.append(item->text()));
//设置item高度
item->setSizeHint(QSize(100,30));
item->setIcon(QIcon(":/image/net.ico"));
item->setWhatsThis(QString::number(id,10));
item->setToolTip(additem);
//设置media的类型
item->setStatusTip(QString::number(MEDIA_TYPE_MUSIC,10));
this->setItemNormalView(item);
//添加到playlist 并将第一条设置为当前播放item
playlist->addMedia(QUrl(link));
// this->setItemPlay(row);
if (playNow){
this->doubleClicked = false;
playlist->setCurrentIndex(row);
}
//qDebug("%d",playlist->currentIndex());
return MEDIA_TYPE_MUSIC;
}
示例12: addMusics
void MusicPage::addMusics(int listId, QQueue<MusicInfo> musics)
{
MusicInfo musicInfo;
MusicList *musicList;
int row;
while (!musics.empty())
{
musicInfo = musics.front();
musics.pop_front();
musicList = (MusicList *)musicLists->widget(listId);
row = musicList->count();
QListWidgetItem *item = new QListWidgetItem(musicList);
item->setSizeHint(QSize(item->sizeHint().width(), 30));
musicList->insertItem(row, item);
MusicListItem *itemwidget = new MusicListItem(musicList);
itemwidget->setName(musicInfo.getName());
itemwidget->setArtist(musicInfo.getArtist());
musicList->setItemWidget(item, itemwidget);
/*
musicList->insertRow(row);
QTableWidgetItem *nameItem = new QTableWidgetItem(musicInfo.getName());
QTableWidgetItem *artiseItem = new QTableWidgetItem(musicInfo.getArtist());
nameItem->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
artiseItem->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
musicList->setItem(row, 0, nameItem);
musicList->setItem(row, 1, artiseItem);
musicList->setCurrentCell(row, 0);
*/
}
}
示例13: insertSlot
void AdvanceButtonDialog::insertSlot()
{
int current = ui->slotListWidget->currentRow();
int count = ui->slotListWidget->count();
if (current != (count - 1))
{
SimpleKeyGrabberButton *blankButton = new SimpleKeyGrabberButton(this);
QListWidgetItem *item = new QListWidgetItem();
ui->slotListWidget->insertItem(current, item);
item->setData(Qt::UserRole, QVariant::fromValue<SimpleKeyGrabberButton*>(blankButton));
QHBoxLayout *layout= new QHBoxLayout();
layout->addWidget(blankButton);
QWidget *widget = new QWidget();
widget->setLayout(layout);
item->setSizeHint(widget->sizeHint());
ui->slotListWidget->setItemWidget(item, widget);
ui->slotListWidget->setCurrentItem(item);
connectButtonEvents(blankButton);
blankButton->refreshButtonLabel();
this->button->insertAssignedSlot(0, 0, current);
updateSlotsScrollArea(0);
}
}
示例14: time
/**
* \brief Add the tasks from a sequence of ids
*
* Any tasks not available from the server are simply ignored
*/
void TaskMainWindow::addTasks(const std::set<long>& taskids) {
debug(LOG_DEBUG, DEBUG_LOG, 0, "adding %d tasks", taskids.size());
time_t now = time(NULL); // needed to recompute timestamps
std::set<long>::const_iterator i;
for (i = taskids.begin(); i != taskids.end(); i++) {
int taskid = *i;
try {
// get the task info
Astro::TaskInfo_var info = taskqueue->info(taskid);
info->lastchange = now - info->lastchange;
// get parameters
Astro::TaskParameters_var params
= taskqueue->parameters(taskid);
// create a list item
QListWidgetItem *lwi = new QListWidgetItem();
lwi->setSizeHint(QSize(300,90));
TaskItem *ti = new TaskItem(info, params);
ui->tasklistWidget->addItem(lwi);
ui->tasklistWidget->setItemWidget(lwi, ti);
} catch (const Astro::NotFound) {
debug(LOG_ERR, DEBUG_LOG, 0, "task %d not found",
taskid);
} catch (const std::exception& x) {
debug(LOG_ERR, DEBUG_LOG, 0,
"cannot get info for task %d", taskid);
}
}
}
示例15: addMusic
void MusicPage::addMusic(QString name, QString artist)
{
MusicList *musicList = (MusicList *)musicLists->currentWidget();
int row = musicList->count();
QListWidgetItem *item = new QListWidgetItem(musicList);
item->setSizeHint(QSize(item->sizeHint().width(), 30));
musicList->insertItem(row, item);
MusicListItem *itemwidget = new MusicListItem(musicList);
itemwidget->setName(name);
itemwidget->setArtist(artist);
musicList->setItemWidget(item, itemwidget);
musicList->setCurrentRow(row);
/*
musicList->insertRow(row);
QTableWidgetItem *nameItem = new QTableWidgetItem(name);
QTableWidgetItem *artiseItem = new QTableWidgetItem(artist);
nameItem->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
artiseItem->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
musicList->setItem(row, 0, nameItem);
musicList->setItem(row, 1, artiseItem);
musicList->setCurrentCell(row, 0);
*/
}