本文整理汇总了C++中QListWidgetItem::setTextAlignment方法的典型用法代码示例。如果您正苦于以下问题:C++ QListWidgetItem::setTextAlignment方法的具体用法?C++ QListWidgetItem::setTextAlignment怎么用?C++ QListWidgetItem::setTextAlignment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QListWidgetItem
的用法示例。
在下文中一共展示了QListWidgetItem::setTextAlignment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QDialog
SettingsDialog::SettingsDialog(QWidget *parent)
: QDialog(parent)
{
setAttribute(Qt::WA_DeleteOnClose);
ui.setupUi(this);
ui.contentsWidget->setMaximumWidth(120);
ui.pagesStackedWidget->addWidget(new SettingsKeysWidget);
ui.pagesStackedWidget->addWidget(new SettingsSSLWidget);
QListWidgetItem *keyButton = new QListWidgetItem(ui.contentsWidget);
keyButton->setIcon(QIcon(":/images/folder_big.png"));
keyButton->setText(tr("Key Locations"));
keyButton->setTextAlignment(Qt::AlignHCenter);
keyButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
QListWidgetItem *sslButton = new QListWidgetItem(ui.contentsWidget);
sslButton->setIcon(QIcon(":/images/key.png"));
sslButton->setText(tr("SSL"));
sslButton->setTextAlignment(Qt::AlignHCenter);
sslButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
ui.contentsWidget->setCurrentRow(0);
connect(ui.contentsWidget,
SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
this, SLOT(changePage(QListWidgetItem *, QListWidgetItem*)));
}
示例2: refreshHistory
void refreshHistory(QString username) {
MainMutex::mutex().lock();
unsigned short id = this->getKeyOfMap(this->_client->getContactList(), username.toStdString());
std::map<unsigned short, std::vector<std::pair<messageType, std::string> > > history = this->_client->getMessagesList();
MainMutex::mutex().unlock();
this->historyList->clear();
if (history[id].empty()) {
QString content(QString::fromUtf8("Vous n'avez encore rien envoyé à votre correspondant ! N'hésitez pas à lui envoyer un petit message pour lui dire bonjour ! :)"));
QListWidgetItem *item = new QListWidgetItem(content);
item->setTextAlignment(Qt::AlignCenter);
this->historyList->addItem(item);
} else {
for (std::vector<std::pair<messageType, std::string> >::iterator it = history[id].begin(); it != history[id].end(); it++) {
QString itemName(it->second.c_str());
QListWidgetItem *item = new QListWidgetItem(itemName);
if (it->first == FROM_ME)
item->setTextAlignment(Qt::AlignRight);
else if (it->first == FROM_OTHER)
item->setTextAlignment(Qt::AlignLeft);
else
item->setTextAlignment(Qt::AlignCenter);
this->historyList->addItem(item);
}
}
}
示例3: createIcons
void ConfigDialog::createIcons()
{
QListWidgetItem *configButton = new QListWidgetItem(contentsWidget);
configButton->setIcon(QIcon(":/images/config.png"));
configButton->setText(tr(" 主页 "));
configButton->setTextAlignment(Qt::AlignHCenter);
configButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
QListWidgetItem *updateButton = new QListWidgetItem(contentsWidget);
updateButton->setIcon(QIcon("image/order.jpg"));
updateButton->setText(tr("信息"));
updateButton->setTextAlignment(Qt::AlignHCenter);
updateButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
QListWidgetItem *queryButton = new QListWidgetItem(contentsWidget);
queryButton->setIcon(QIcon("image/equipment.jpg"));
queryButton->setText(tr("器材"));
queryButton->setTextAlignment(Qt::AlignHCenter);
queryButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
if (current_user == "admin") {
QListWidgetItem *userButton = new QListWidgetItem(contentsWidget);
userButton->setIcon(QIcon("image/user.jpg"));
userButton->setText(tr("用户"));
userButton->setTextAlignment(Qt::AlignHCenter);
userButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
}
connect(contentsWidget,
SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
this, SLOT(changePage(QListWidgetItem*,QListWidgetItem*)));
}
示例4: ErstelleIcons
void EinstellungsdialogImpl::ErstelleIcons()
{
QListWidgetItem *DatenbankButton = new QListWidgetItem(listWidget);
DatenbankButton->setIcon(QIcon(":/dlg_einstellungen/datenbank.png"));
DatenbankButton->setText(trUtf8("Datenbank"));
DatenbankButton->setTextAlignment(Qt::AlignHCenter);
DatenbankButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
QListWidgetItem *FarbauswahlButton = new QListWidgetItem(listWidget);
FarbauswahlButton->setIcon(QIcon(":/dlg_einstellungen/farbauswahl.png"));
FarbauswahlButton->setText(trUtf8("Farbauswahl"));
FarbauswahlButton->setTextAlignment(Qt::AlignHCenter);
FarbauswahlButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
QListWidgetItem *KonfigButton = new QListWidgetItem(listWidget);
KonfigButton->setIcon(QIcon(":/dlg_einstellungen/erweitert.png"));
KonfigButton->setText(trUtf8("Erweitert"));
KonfigButton->setTextAlignment(Qt::AlignHCenter);
KonfigButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
QListWidgetItem *AnsichtButton = new QListWidgetItem(listWidget);
AnsichtButton->setIcon(QIcon(":/dlg_einstellungen/auge.png"));
AnsichtButton->setText(trUtf8("Ansicht"));
AnsichtButton->setTextAlignment(Qt::AlignHCenter);
AnsichtButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
connect(listWidget,
SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
this, SLOT(SeiteWechseln(QListWidgetItem*,QListWidgetItem*)));
}
示例5: createIcons
void ConfigDialog::createIcons()
{
QListWidgetItem *configButton = new QListWidgetItem(contentsWidget);
configButton->setIcon(QIcon(":/images/config.png"));
configButton->setText(tr("Settings"));
configButton->setTextAlignment(Qt::AlignHCenter);
configButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
QListWidgetItem *cyclistButton = new QListWidgetItem(contentsWidget);
cyclistButton->setIcon(QIcon(":images/cyclist.png"));
cyclistButton->setText(tr("Athlete"));
cyclistButton->setTextAlignment(Qt::AlignHCenter);
cyclistButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
QListWidgetItem *realtimeButton = new QListWidgetItem(contentsWidget);
realtimeButton->setIcon(QIcon(":images/arduino.png"));
realtimeButton->setText(tr("Devices"));
realtimeButton->setTextAlignment(Qt::AlignHCenter);
realtimeButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
#ifdef GC_HAVE_LIBOAUTH
QListWidgetItem *twitterButton = new QListWidgetItem(contentsWidget);
twitterButton->setIcon(QIcon(":images/twitter.png"));
twitterButton->setText(tr("Twitter"));
twitterButton->setTextAlignment(Qt::AlignHCenter);
twitterButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
#endif
connect(contentsWidget,
SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
this, SLOT(changePage(QListWidgetItem *, QListWidgetItem*)));
connect(saveButton, SIGNAL(clicked()), this, SLOT(save_Clicked()));
}
示例6: createIcons
void ConfigWidget::createIcons()
{
QListWidgetItem *configButton = new QListWidgetItem(contentsWidget);
configButton->setIcon(QIcon(":/images/network.png"));
configButton->setText(tr("Network Settings"));
configButton->setTextAlignment(Qt::AlignHCenter);
configButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
QListWidgetItem *queryButton = new QListWidgetItem(contentsWidget);
queryButton->setIcon(QIcon(":/images/settings.png"));
queryButton->setText(tr("Controller Settings"));
queryButton->setTextAlignment(Qt::AlignHCenter);
queryButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
QListWidgetItem *consoleButton = new QListWidgetItem(contentsWidget);
consoleButton->setIcon(QIcon(":/images/console.png"));
consoleButton->setText(tr("Console / Ouptut"));
consoleButton->setTextAlignment(Qt::AlignHCenter);
consoleButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
QListWidgetItem *gameButton = new QListWidgetItem(contentsWidget);
gameButton->setIcon(QIcon(":/images/game.png"));
gameButton->setText(tr("Game: Tetrix"));
gameButton->setTextAlignment(Qt::AlignHCenter);
gameButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
connect(contentsWidget,
SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
this, SLOT(changePage(QListWidgetItem*,QListWidgetItem*)));
}
示例7: 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* ) ) );
}
示例8: createIcons
void PreferencesDialog::createIcons()
// ----------------------------------------------------------------------------
// Add one icon per preference page
// ----------------------------------------------------------------------------
{
// general.png downloaded from:
// http://www.iconfinder.com/icondetails/17814/128/preferences_settings_tools_icon
// Author: Everaldo Coelho (Crystal Project)
// License: LGPL
QListWidgetItem *generalButton = new QListWidgetItem(contentsWidget);
generalButton->setIcon(QIcon(":/images/general.png"));
generalButton->setText(tr("General options"));
generalButton->setTextAlignment(Qt::AlignHCenter);
generalButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
// performances.png downloaded from:
// http://www.iconfinder.com/icondetails/47542/128/performance_settings_speed_icon
// Author: webiconset.com
// License: Free for commercial use (Do not redistribute)
QListWidgetItem *perfButton = new QListWidgetItem(contentsWidget);
perfButton->setIcon(QIcon(":/images/performances.png"));
perfButton->setText(tr("Performances"));
perfButton->setTextAlignment(Qt::AlignHCenter);
perfButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
#ifndef CFG_NOMODPREF
// modules.png downloaded from:
// http://www.iconfinder.com/icondetails/17854/128/cubes_modules_icon
// Author: Everaldo Coelho (Crystal Project)
// License: LGPL
QListWidgetItem *modulesButton = new QListWidgetItem(contentsWidget);
modulesButton->setIcon(QIcon(":/images/modules.png"));
modulesButton->setText(tr("Module options"));
modulesButton->setTextAlignment(Qt::AlignHCenter);
modulesButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
#endif
#ifdef DEBUG
// bug.png downloaded from:
// http://www.iconfinder.com/icondetails/17857/128/animal_bug_insect_ladybird_icon
// Author: Everaldo Coelho (Crystal Project)
// License: LGPL
QListWidgetItem *debugButton = new QListWidgetItem(contentsWidget);
debugButton->setIcon(QIcon(":/images/bug.png"));
debugButton->setText(tr("Debug options"));
debugButton->setTextAlignment(Qt::AlignHCenter);
debugButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
#endif
connect(contentsWidget,
SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
this, SLOT(changePage(QListWidgetItem*,QListWidgetItem*)));
}
示例9: setupWidgets
void ConfigDialog::setupWidgets()
{
// list of topics
topicList = new QListWidget();
topicList->setViewMode(QListView::IconMode);
topicList->setIconSize(QSize(64, 64));
topicList->setMovement(QListView::Static);
topicList->setMaximumWidth(128);
topicList->setGridSize(QSize(100, 100));
topicList->setMinimumHeight(300);
// add topics
QListWidgetItem* general = new QListWidgetItem(QIcon(":/images/exec.png"), tr("General"));
general->setTextAlignment(Qt::AlignHCenter);
topicList->addItem(general);
QListWidgetItem* editor = new QListWidgetItem(QIcon(":/images/kedit.png"), tr("Editor"));
editor->setTextAlignment(Qt::AlignHCenter);
topicList->addItem(editor);
// create pages
configStack = new QStackedWidget();
generalpage = new GeneralPage();
configStack->addWidget(generalpage);
editorpage = new EditorPage();
configStack->addWidget(editorpage);
connect(topicList, SIGNAL(currentRowChanged(int)), configStack, SLOT(setCurrentIndex(int)));
topicList->setCurrentRow(0);
// buttons
okButton = new QPushButton(tr("Ok"));
cancelButton = new QPushButton(tr("Cancel"));
connect(okButton, SIGNAL(clicked()), SLOT(accept()));
connect(cancelButton, SIGNAL(clicked()), SLOT(reject()));
// main layout
QHBoxLayout* contentLayout = new QHBoxLayout();
contentLayout->addWidget(topicList);
contentLayout->addWidget(configStack);
QHBoxLayout* buttonLayout = new QHBoxLayout();
buttonLayout->addStretch();
buttonLayout->addWidget(okButton);
buttonLayout->addWidget(cancelButton);
QVBoxLayout* mainLayout = new QVBoxLayout();
mainLayout->addLayout(contentLayout);
mainLayout->addLayout(buttonLayout);
setLayout(mainLayout);
setWindowTitle(tr("Aseba Studio - Settings"));
readSettings();
}
示例10: 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);
}
示例11: createIcons
//创建图标
void ConfigDialog::createIcons()
{
//常规设置
QListWidgetItem *generalSettingsItem = new QListWidgetItem(contentsWidget);
generalSettingsItem->setIcon(QIcon(":/images/generalSettingsButton.png"));
generalSettingsItem->setText(tr("常规设置"));
generalSettingsItem->setTextAlignment(Qt::AlignCenter);
generalSettingsItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
//下载设置
QListWidgetItem *downloadSettingsItem = new QListWidgetItem(contentsWidget);
downloadSettingsItem->setIcon(QIcon(":/images/downloadSettingsButton.png"));
downloadSettingsItem->setText(tr("下载设置"));
downloadSettingsItem->setTextAlignment(Qt::AlignCenter);
downloadSettingsItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
//歌词设置
QListWidgetItem *lrcSettingsItem = new QListWidgetItem(contentsWidget);
lrcSettingsItem->setIcon(QIcon(":/images/lrcSettingsButton.png"));
lrcSettingsItem->setText(tr("歌词设置"));
lrcSettingsItem->setTextAlignment(Qt::AlignCenter);
lrcSettingsItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
//热键设置
QListWidgetItem *hotKeysSettingsItem = new QListWidgetItem(contentsWidget);
hotKeysSettingsItem->setIcon(QIcon(":/images/hotKeysSettingsButton.png"));
hotKeysSettingsItem->setText(tr("热键设置"));
hotKeysSettingsItem->setTextAlignment(Qt::AlignCenter);
hotKeysSettingsItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
//代理设置
//QListWidgetItem *proxySettingsItem = new QListWidgetItem(contentsWidget);
//proxySettingsItem->setIcon(QIcon(":/images/proxySettingsButton.png"));
//proxySettingsItem->setText(tr("代理设置"));
//proxySettingsItem->setTextAlignment(Qt::AlignCenter);
//proxySettingsItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
//更新页面
QListWidgetItem *updateItem = new QListWidgetItem(contentsWidget);
updateItem->setIcon(QIcon(":/images/updateButton.png"));
updateItem->setText(tr("软件更新"));
updateItem->setTextAlignment(Qt::AlignCenter);
updateItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
connect(contentsWidget,
SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
this, SLOT(slot_ChangePage(QListWidgetItem*,QListWidgetItem*)));
}
示例12: createIcons
void SettingsDialog::createIcons()
{
QListWidgetItem *configButton = new QListWidgetItem(contentsWidget);
QIcon config = QIcon::fromTheme("preferences-system", QIcon(":/images/config.png"));
configButton->setIcon(config);
configButton->setText(tr("Configuration"));
configButton->setTextAlignment(Qt::AlignHCenter);
configButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
/*
QListWidgetItem *updateButton = new QListWidgetItem(contentsWidget);
updateButton->setIcon(QIcon(":/images/update.png"));
updateButton->setText(tr("Update"));
updateButton->setTextAlignment(Qt::AlignHCenter);
updateButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
QListWidgetItem *queryButton = new QListWidgetItem(contentsWidget);
queryButton->setIcon(QIcon(":/images/query.png"));
queryButton->setText(tr("Query"));
queryButton->setTextAlignment(Qt::AlignHCenter);
queryButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
*/
connect(contentsWidget,
SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
this, SLOT(changePage(QListWidgetItem*,QListWidgetItem*)));
}
示例13: createNewRow
void ListTable::createNewRow()
{
QListWidgetItem * item = 0;
switch (type_)
{
case ListEditor::INT:
item = new QListWidgetItem("0");
break;
case ListEditor::FLOAT:
item = new QListWidgetItem("0.0");
break;
default:
item = new QListWidgetItem("");
}
item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
addItem(item);
setItemSelected(item, true);
setCurrentRow(row(item));
itemActivated(item);
edit(currentIndex());
}
示例14: addPage
void BtConfigDialog::addPage(BtConfigPage* pageWidget)
{
// this is a friend
pageWidget->m_parentDialog = this;
QVBoxLayout* containerLayout = new QVBoxLayout;
QLabel* headerLabel = CToolClass::explanationLabel(pageWidget, pageWidget->header(), pageWidget->label());
containerLayout->addWidget(headerLabel);
containerLayout->addWidget(pageWidget);
QWidget* containerWidget = new QWidget(m_pageWidget);
containerWidget->setLayout(containerLayout);
m_pageWidget->addWidget(containerWidget);
QListWidgetItem* item = new QListWidgetItem(m_contentsList);
item->setIcon(util::filesystem::DirectoryUtil::getIcon(pageWidget->iconName()));
item->setText(pageWidget->header());
item->setTextAlignment(Qt::AlignHCenter);
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
//set the list width - it may bee too wide (if there were no pages) or too narrow
if (m_maxItemWidth < m_contentsList->visualItemRect(item).width()) {
m_maxItemWidth = m_contentsList->visualItemRect(item).width();
m_contentsList->setFixedWidth( m_maxItemWidth + (m_contentsList->frameWidth()*2) );
}
// all items should has the same width
for(int i = 0; i < m_contentsList->count(); ++i) {
m_contentsList->item(i)->setSizeHint(QSize(m_maxItemWidth, m_contentsList->visualItemRect(m_contentsList->item(i)).height()) );
}
slotChangePage(m_contentsList->row(item));
}
示例15: setupGeneralFrame
void PreferencesDialog::setupGeneralFrame()
{
promptOverwriteCheck = new QCheckBox("Prompt when overwriting existing files");
promptCloseUnsavedCheck = new QCheckBox("Prompt when closing unsaved files");
QGroupBox* promptGroup = new QGroupBox("Warnings");
QVBoxLayout* vLayout = new QVBoxLayout();
vLayout->addWidget(promptOverwriteCheck);
vLayout->addWidget(promptCloseUnsavedCheck);
promptGroup->setLayout(vLayout);
QFrame* generalFrame = new QFrame();
vLayout = new QVBoxLayout();
vLayout->addWidget(promptGroup);
vLayout->addWidget(new QWidget(), 100);
vLayout->setContentsMargins(0, 0, 0, 0);
generalFrame->setLayout(vLayout);
QListWidgetItem *item = new QListWidgetItem("General");
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
item->setTextAlignment(Qt::AlignCenter);
item->setIcon(QIcon(":/icons/oxygen/configure.png"));
listWidget->addItem(item);
stackedWidget->addWidget(generalFrame);
}