本文整理汇总了C++中ListWidget类的典型用法代码示例。如果您正苦于以下问题:C++ ListWidget类的具体用法?C++ ListWidget怎么用?C++ ListWidget使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ListWidget类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
ListWidget w;
w.show();
return a.exec();
}
示例2: selectPlayer
void OptionsScreenPlayers::selectPlayer(const irr::core::stringw& name)
{
ListWidget* players = this->getWidget<ListWidget>("players");
assert(players != NULL);
players->selectItemWithLabel(name);
players->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
}
示例3: QWidget
QWidget *WalkmeshManager::buildWalkmeshPage()
{
QWidget *ret = new QWidget(this);
ListWidget *listWidget = new ListWidget(ret);
listWidget->addAction(ListWidget::Add, tr("Ajouter triangle"), this, SLOT(addTriangle()));
listWidget->addAction(ListWidget::Rem, tr("Supprimer triangle"), this, SLOT(removeTriangle()));
idToolbar = listWidget->toolBar();
idList = listWidget->listWidget();
idVertices[0] = new VertexWidget(ret);
idVertices[1] = new VertexWidget(ret);
idVertices[2] = new VertexWidget(ret);
idAccess[0] = new QSpinBox(ret);
idAccess[1] = new QSpinBox(ret);
idAccess[2] = new QSpinBox(ret);
idAccess[0]->setRange(-32768, 32767);
idAccess[1]->setRange(-32768, 32767);
idAccess[2]->setRange(-32768, 32767);
QHBoxLayout *accessLayout0 = new QHBoxLayout;
accessLayout0->addWidget(new QLabel(tr("Triangle accessible via la ligne 1-2 :")));
accessLayout0->addWidget(idAccess[0]);
QHBoxLayout *accessLayout1 = new QHBoxLayout;
accessLayout1->addWidget(new QLabel(tr("Triangle accessible via la ligne 2-3 :")));
accessLayout1->addWidget(idAccess[1]);
QHBoxLayout *accessLayout2 = new QHBoxLayout;
accessLayout2->addWidget(new QLabel(tr("Triangle accessible via la ligne 3-1 :")));
accessLayout2->addWidget(idAccess[2]);
QGridLayout *layout = new QGridLayout(ret);
layout->addWidget(listWidget, 0, 0, 7, 1, Qt::AlignLeft);
layout->addWidget(new QLabel(tr("Point 1 :")), 0, 1);
layout->addWidget(idVertices[0], 0, 2);
layout->addWidget(new QLabel(tr("Point 2 :")), 1, 1);
layout->addWidget(idVertices[1], 1, 2);
layout->addWidget(new QLabel(tr("Point 3 :")), 2, 1);
layout->addWidget(idVertices[2], 2, 2);
layout->addLayout(accessLayout0, 3, 1, 1, 2);
layout->addLayout(accessLayout1, 4, 1, 1, 2);
layout->addLayout(accessLayout2, 5, 1, 1, 2);
layout->setRowStretch(6, 1);
connect(idList, SIGNAL(currentRowChanged(int)), SLOT(setCurrentId(int)));
connect(idVertices[0], SIGNAL(valuesChanged(Vertex_s)), SLOT(editIdTriangle(Vertex_s)));
connect(idVertices[1], SIGNAL(valuesChanged(Vertex_s)), SLOT(editIdTriangle(Vertex_s)));
connect(idVertices[2], SIGNAL(valuesChanged(Vertex_s)), SLOT(editIdTriangle(Vertex_s)));
connect(idAccess[0], SIGNAL(valueChanged(int)), SLOT(editIdAccess(int)));
connect(idAccess[1], SIGNAL(valueChanged(int)), SLOT(editIdAccess(int)));
connect(idAccess[2], SIGNAL(valueChanged(int)), SLOT(editIdAccess(int)));
return ret;
}
示例4: showPDFView
void MainWindow::showPDFView(QListWidgetItem *item)
{
ListWidget *w = (ListWidget*)(ui->lstResults->itemWidget(item));
Poppler::Document *document = Poppler::Document::load(w->getPath());
PDFview *view = new PDFview(document,w->getPage(), readerPath, w->getPath());
view->setAttribute(Qt::WA_DeleteOnClose);
view->setWindowTitle("PDF Folder Search");
view->showMaximized();
}
示例5: onNewPlayerWithName
void OptionsScreenPlayers::onNewPlayerWithName(const stringw& newName)
{
ListWidget* players = this->getWidget<ListWidget>("players");
if (players != NULL)
{
core::stringc newNameC(newName.c_str());
players->addItem( newNameC.c_str(), translations->fribidize(newName) );
}
}
示例6: GetValue
void ListBoxImpl::GetValue(int n, char *value, int len)
{
ListWidget *list = static_cast<ListWidget *>(wid);
QListWidgetItem *item = list->item(n);
QString str = item->data(Qt::DisplayRole).toString();
QByteArray bytes = unicodeMode ? str.toUtf8() : str.toLocal8Bit();
strncpy(value, bytes.constData(), len);
value[len-1] = '\0';
}
示例7: ListWidget
void ListBoxImpl::Create(Window &parent,
int /*ctrlID*/,
Point location,
int /*lineHeight*/,
bool unicodeMode_,
int)
{
unicodeMode = unicodeMode_;
QWidget *qparent = static_cast<QWidget *>(parent.GetID());
ListWidget *list = new ListWidget(qparent);
#if defined(Q_OS_WIN)
// On Windows, Qt::ToolTip causes a crash when the list is clicked on
// so Qt::Tool is used.
list->setParent(0, Qt::Tool | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
#else
// On OS X, Qt::Tool takes focus so main window loses focus so
// keyboard stops working. Qt::ToolTip works but its only really
// documented for tooltips.
// On Linux / X this setting allows clicking on list items.
list->setParent(0, Qt::ToolTip | Qt::FramelessWindowHint);
#endif
list->setAttribute(Qt::WA_ShowWithoutActivating);
list->setFocusPolicy(Qt::NoFocus);
list->setUniformItemSizes(true);
list->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
list->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
list->move(location.x, location.y);
wid = list;
}
示例8: main
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
ListWidget window;
window.setWindowTitle("QListWidget");
window.show();
return app.exec();
}
示例9: Find
int ListBoxImpl::Find(const char *prefix)
{
ListWidget *list = static_cast<ListWidget *>(wid);
QString sPrefix = unicodeMode ? QString::fromUtf8(prefix) : QString::fromLocal8Bit(prefix);
QList<QListWidgetItem *> ms = list->findItems(sPrefix, Qt::MatchStartsWith);
int result = -1;
if (!ms.isEmpty()) {
result = list->row(ms.first());
}
return result;
}
示例10: addTracks
/** Updates the list of tracks shown.
*/
void GPInfoScreen::addTracks()
{
const std::vector<std::string> tracks = m_gp.getTrackNames();
ListWidget *list = getWidget<ListWidget>("tracks");
list->clear();
for (unsigned int i = 0; i < (unsigned int)tracks.size(); i++)
{
const Track *track = track_manager->getTrack(tracks[i]);
std::string s = StringUtils::toString(i);
list->addItem(s, translations->fribidize(track->getName()));
}
} // addTracks
示例11: CaretFromEdge
int ListBoxImpl::CaretFromEdge()
{
ListWidget *list = static_cast<ListWidget *>(wid);
int maxIconWidth = 0;
foreach (QPixmap im, images) {
if (maxIconWidth < im.width())
maxIconWidth = im.width();
}
// The '7' is from trial and error on Windows - there may be
// a better programmatic way to find any padding factors.
return maxIconWidth + (2 * list->frameWidth()) + 7;
}
示例12: if
void OptionsScreenPlayers::eventCallback(Widget* widget, const std::string& name, const int playerID)
{
if (name == "options_choice")
{
std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER).c_str();
if (selection == "tab_audio") StateManager::get()->replaceTopMostScreen(OptionsScreenAudio::getInstance());
else if (selection == "tab_video") StateManager::get()->replaceTopMostScreen(OptionsScreenVideo::getInstance());
else if (selection == "tab_players") StateManager::get()->replaceTopMostScreen(OptionsScreenPlayers::getInstance());
else if (selection == "tab_controls") StateManager::get()->replaceTopMostScreen(OptionsScreenInput::getInstance());
else if (selection == "tab_ui") StateManager::get()->replaceTopMostScreen(OptionsScreenUI::getInstance());
}
else if (name == "back")
{
StateManager::get()->escapePressed();
}
else if (name == "addplayer")
{
new EnterPlayerNameDialog(this, 0.5f, 0.4f);
}
else if (name == "players")
{
// Find which player in the list was clicked
ListWidget* players = this->getWidget<ListWidget>("players");
assert(players != NULL);
core::stringw selectedPlayer = players->getSelectionLabel();
const int player_amount = PlayerManager::get()->getNumPlayers();
for (int i=0; i<player_amount; i++)
{
PlayerProfile *player = PlayerManager::get()->getPlayer(i);
if (selectedPlayer == translations->fribidize(player->getName()))
{
if (!(player->isGuestAccount()))
{
new PlayerInfoDialog( player, 0.5f, 0.6f );
}
return;
}
} // end for
}
else if (name == "playername")
{
race_manager->clearKartLastPositionOnOverworld();
PlayerManager::get()->setCurrentPlayer(NULL,false);
StateManager::get()->pushScreen(StoryModeLobbyScreen::getInstance());
}
} // eventCallback
示例13: assert
void OptionsScreenInput::rebuildDeviceList()
{
/*
DynamicRibbonWidget* devices = this->getWidget<DynamicRibbonWidget>("devices");
assert( devices != NULL );
devices->clearItems();
buildDeviceList();
devices->updateItemDisplay();
*/
ListWidget* devices = this->getWidget<ListWidget>("devices");
assert( devices != NULL );
devices->clear();
buildDeviceList();
} // rebuildDeviceList
示例14: if
void StoryModeLobbyScreen::eventCallback(Widget* widget, const std::string& name, const int playerID)
{
if (name == "back")
{
StateManager::get()->escapePressed();
}
else if (name == "creategame")
{
new EnterPlayerNameDialog(this, 0.5f, 0.4f);
}
else if (name == "gameslots")
{
ListWidget* list = getWidget<ListWidget>("gameslots");
bool slot_found = false;
PtrVector<PlayerProfile>& players = UserConfigParams::m_all_players;
for (int n=0; n<players.size(); n++)
{
if (list->getSelectionLabel() == players[n].getName())
{
unlock_manager->setCurrentSlot(players[n].getUniqueID());
unlock_manager->updateActiveChallengeList();
slot_found = true;
break;
}
}
if (!slot_found)
{
fprintf(stderr, "[StoryModeLobbyScreen] ERROR: cannot find player corresponding to slot '%s'\n",
core::stringc(list->getSelectionLabel().c_str()).c_str());
}
else
{
CheckBoxWidget* cb = getWidget<CheckBoxWidget>("rememberme");
if (cb->getState())
{
UserConfigParams::m_default_player = list->getSelectionLabel();
}
}
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
}
} // eventCallback
示例15: GetDesiredRect
PRectangle ListBoxImpl::GetDesiredRect()
{
ListWidget *list = static_cast<ListWidget *>(wid);
int rows = Length();
if (rows == 0 || rows > visibleRows) {
rows = visibleRows;
}
int rowHeight = list->sizeHintForRow(0);
int height = (rows * rowHeight) + (2 * list->frameWidth());
QStyle *style = QApplication::style();
int width = list->sizeHintForColumn(0) + (2 * list->frameWidth());
if (Length() > rows) {
width += style->pixelMetric(QStyle::PM_ScrollBarExtent);
}
return PRectangle(0, 0, width, height);
}