本文整理汇总了C++中ListView类的典型用法代码示例。如果您正苦于以下问题:C++ ListView类的具体用法?C++ ListView怎么用?C++ ListView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ListView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createWeatherPage
void WeatherGuesserApp::createWeatherPage()
{
QmlDocument *qml = QmlDocument::create().load("WeatherPage.qml");
if (!qml->hasErrors()) {
mWeatherPage = qml->createRootNode<Page>();
if (mWeatherPage) {
// Set up a weather model the list, the model will load weather data
ListView *weatherList = mWeatherPage->findChild<ListView*>("weatherList");
WeatherModel *weatherModel = new WeatherModel(this);
weatherList->setDataModel(weatherModel);
// Connect the weather model to page signals that updates city for which model should be shown.
connect(mContinentCitiesPage, SIGNAL(showWeather(QString)), weatherModel,
SLOT(onUpdateWeatherCity(QString)));
Page *favorites = mNavigation->findChild<Page*>("favorites");
connect(favorites, SIGNAL(showWeather(QString)), weatherModel,
SLOT(onUpdateWeatherCity(QString)));
qml->documentContext()->setContextProperty("_navigation", mNavigation);
}
}
}
示例2: createCitiesPage
void WeatherGuesserApp::createCitiesPage()
{
QmlDocument *qml = QmlDocument::create().load("ContinentCitiesPage.qml");
if (!qml->hasErrors()) {
mContinentCitiesPage = qml->createRootNode<Page>();
if (mContinentCitiesPage) {
// Set up a cities model for the page, this model will load different cities depending
// on which continent is selected.
ListView *citiesList = mContinentCitiesPage->findChild<ListView*>("citiesList");
CityModel *cityModel = new CityModel(QStringList() << "name", "continents_connection",
this);
citiesList->setDataModel(cityModel);
// Connect to the continents page custom signal.
Page *continents = mNavigation->findChild<Page*>("continents");
connect(continents, SIGNAL(showContinentCities(QString)), cityModel,
SLOT(onChangeContinent(QString)));
qml->documentContext()->setContextProperty("_navigation", mNavigation);
}
}
}
示例3: GroupDataModel
ListView *QuotesApp::setUpQuotesList()
{
ListView *listView = 0;
// Load the quotes table from the database.
QVariantList sqlData = mQuotesDbHelper->loadDataBase("quotes.db", "quotes");
if (!sqlData.isEmpty()) {
// A GroupDataModel is used for creating a sorted list.
mDataModel = new GroupDataModel(QStringList() << "lastname" << "firstname");
mDataModel->setParent(this);
mDataModel->setGrouping(ItemGrouping::ByFirstChar);
mDataModel->insert(sqlData);
// The list view is set up in QML, here we retrieve it to connect it to
// a data model.
listView = mNav->findChild<ListView*>("quotesList");
listView->setDataModel(mDataModel);
// By connecting to the selectionChanged signal we can find out when selection has
// changed and update the content pane information based on the selected item.
QObject::connect(listView, SIGNAL(selectionChanged(const QVariantList, bool)), this,
SLOT(onListSelectionChanged(const QVariantList, bool)));
// Connect to the models item added and updated signals, since we want to
// select the item in the list if it has been manipulated.
QObject::connect(mDataModel, SIGNAL(itemAdded(QVariantList)), this,
SLOT(onModelUpdate(QVariantList)));
QObject::connect(mDataModel, SIGNAL(itemUpdated(QVariantList)), this,
SLOT(onModelUpdate(QVariantList)));
}
示例4: switch
void TrialPanel::selectedItemEvent(Ref *pSender, ListView::EventType type)
{
switch (type)
{
case cocos2d::ui::ListView::EventType::ON_SELECTED_ITEM_START:
{
ListView* listView = static_cast<ListView*>(pSender);
CC_UNUSED_PARAM(listView);
CCLOG("select child start index = %ld", listView->getCurSelectedIndex());
//auto tag = listView->getItem(listView->getCurSelectedIndex())->getTag();
//auto endStatUnit = _endStatsUnit.at(listView->getCurSelectedIndex());
break;
}
case cocos2d::ui::ListView::EventType::ON_SELECTED_ITEM_END:
{
ListView* listView = static_cast<ListView*>(pSender);
CC_UNUSED_PARAM(listView);
CCLOG("select child end index = %ld", listView->getCurSelectedIndex());
/*auto unit = listView->getItem(listView->getCurSelectedIndex());
auto achieve = static_cast<Achievement*>(unit->getUserData());*/
break;
}
default:
break;
}
}
示例5: WeatherModel
void WeatherGuesserApp::setUpHomePage()
{
mHomeCityPage = mNavigation->findChild<Page*>("homeCityPage");
// Set a weather model
ListView *weatherList = mHomeCityPage->findChild<ListView*>("weatherList");
WeatherModel *homeWeatherModel = new WeatherModel(this);
weatherList->setDataModel(homeWeatherModel);
// The home town can be set from two different lists, so we have to connect to
// their signals
ListView *favList = mNavigation->findChild<ListView*>("favoritesList");
connect(favList, SIGNAL(updateHomeCity(QString)), homeWeatherModel,
SLOT(onUpdateWeatherCity(QString)));
ListView *citiesList = mContinentCitiesPage->findChild<ListView*>("citiesList");
connect(citiesList, SIGNAL(updateHomeCity(QString)), homeWeatherModel,
SLOT(onUpdateWeatherCity(QString)));
// In addition we connect the application to the same signals so we can store the home town in the app settings.
connect(favList, SIGNAL(updateHomeCity(QString)), this, SLOT(onUpdateHomeCity(QString)));
connect(citiesList, SIGNAL(updateHomeCity(QString)), this, SLOT(onUpdateHomeCity(QString)));
// Start loading weather data for the home page, if no home town is stored in
// the application settings London is loaded as the home town.
QSettings settings;
QString homeTown = "London";
if (!settings.value("homeCity").isNull()) {
homeTown = settings.value("homeCity").toString();
}
homeWeatherModel->onUpdateWeatherCity(homeTown);
mHomeCityPage->setProperty("city", QVariant(homeTown));
}
示例6: VerticalLayout
/**
* Creates and adds main layout to the screen.
*/
void SettingsScreen::createMainLayout()
{
VerticalLayout* mainLayout = new VerticalLayout();
Screen::setMainWidget(mainLayout);
ListView* listView = new ListView();
listView->fillSpaceHorizontally();
listView->fillSpaceVertically();
mainLayout->addChild(listView);
ListViewItem* listItem;
// Add IP label and edit box
mIPEditBox = new EditBox();
mIPEditBox->setInputMode(EDIT_BOX_INPUT_MODE_NUMERIC);
listView->addChild(this->createListViewItem(IP_LABEL_TEXT, mIPEditBox));
// Add port label and edit box
mPortEditBox = new EditBox();
mPortEditBox->setInputMode(EDIT_BOX_INPUT_MODE_NUMERIC);
listView->addChild(this->createListViewItem(PORT_LABEL_TEXT, mPortEditBox));
if ( isAndroid() )
{
mShowOnlyIfInBackground = new CheckBox();
mShowOnlyIfInBackground->setState(true);
listView->addChild(createListViewItem(SHOW_ONLY_IF_NOT_RUNNING, mShowOnlyIfInBackground));
mTickerText = new EditBox();
mTickerText->setText(TICKER_DEFAULT);
listView->addChild(createListViewItem(TICKER_LABEL, mTickerText));
mContentTitle = new EditBox();
mContentTitle->setText(TITLE_DEFAULT);
listView->addChild(createListViewItem(TITLE_LABEL, mContentTitle));
}
// Android: If the registrationID was already saved from previous launches,
// do not connect again.
MAHandle myStore = maOpenStore("MyStore", 0);
if ( isAndroid() && myStore == STERR_NONEXISTENT
||
!isAndroid() )
{
// Add connection status label.
listItem = new ListViewItem;
listView->addChild(listItem);
mConnectionStatusLabel = new Label();
mConnectionStatusLabel->setText(CONNECTION_NOT_ESTABLISHED);
listItem->addChild(mConnectionStatusLabel);
listItem = new ListViewItem;
listView->addChild(listItem);
mConnectButton = new Button();
mConnectButton->setText(CONNECT_BUTTON_TEXT);
listItem->addChild(mConnectButton);
}
}
示例7: lua_cocos2dx_ListView_addEventListenerListView
static int lua_cocos2dx_ListView_addEventListenerListView(lua_State* L)
{
if (nullptr == L)
return 0;
int argc = 0;
ListView* self = nullptr;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
if (!tolua_isusertype(L,1,"ccui.ListView",0,&tolua_err)) goto tolua_lerror;
#endif
self = static_cast<ListView*>(tolua_tousertype(L,1,0));
#if COCOS2D_DEBUG >= 1
if (nullptr == self) {
tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_ListView_addEventListenerListView'\n", NULL);
return 0;
}
#endif
argc = lua_gettop(L) - 1;
if (1 == argc)
{
#if COCOS2D_DEBUG >= 1
if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err))
{
goto tolua_lerror;
}
#endif
LuaCocoStudioEventListener* listern = LuaCocoStudioEventListener::create();
if (nullptr == listern)
{
tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL);
return 0;
}
LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0));
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listern, handler, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER);
self->setUserObject(listern);
self->addEventListenerListView(listern, listvieweventselector(LuaCocoStudioEventListener::eventCallbackFunc));
return 0;
}
CCLOG("'addEventListenerListView' function of ListView has wrong number of arguments: %d, was expecting %d\n", argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(L,"#ferror in function 'addEventListenerListView'.",&tolua_err);
return 0;
#endif
}
示例8: main
int main(int argc, char **argv) {
QApplication app(argc, argv);
ListView *piv = new ListView();
app.setMainWidget(piv);
piv->show();
return app.exec();
}
示例9: Application_processMessageQueue
static void Application_processMessageQueue() {
while(!messageQueue.empty()) {
Message message = messageQueue.takeFirst();
if(message.type == Message::Type::ListView_OnActivate) {
ListView* listView = (ListView*)message.object;
if(listView->onActivate) listView->onActivate();
}
}
}
示例10: VerticalLayout
/**
* Creates and adds main layout to the screen.
*/
void SettingsScreen::createMainLayout() {
// Create and add the main layout to the screen.
VerticalLayout* mainLayout = new VerticalLayout();
Screen::setMainWidget(mainLayout);
ListView* listView = new ListView();
mainLayout->addChild(listView);
// Add set duration option row.
this->addSetDurationRow(listView);
// Add get duration option row.
this->addGetDurationRow(listView);
// Add options for setting and getting the video quality value.
this->addVideoQualityRows(listView);
if ( isIOS())
{
// Add options for setting and getting the flash mode value.
this->addFlashModeRows(listView);
// Add option for setting the camera roll flag.
this->addCameraRollFlagRow(listView);
// Add option for setting the camera controls flag.
this->addCameraControlsFlagRow(listView);
}
// Add take picture button.
mTakePictureBtn = new Button();
mTakePictureBtn->setText(TAKE_PICTURE_BTN_TEXT);
this->addButtonToListView(mTakePictureBtn, listView);
if (isAndroid())
{
mTakenPicturePath = new Label();
ListViewItem* listItem = new ListViewItem();
listItem->addChild(mTakenPicturePath);
listView->addChild(listItem);
}
// Add record video button.
mRecordVideoBtn = new Button();
mRecordVideoBtn->setText(RECORD_VIDEO_BTN_TEXT);
this->addButtonToListView(mRecordVideoBtn, listView);
// Add show image button.
mShowImageScreen = new Button();
mShowImageScreen->setText(SHOW_IMAGE_SCREEN_TEXT);
this->addButtonToListView(mShowImageScreen, listView);
// Add show video screen button.
mShowVideoScreen = new Button();
mShowVideoScreen->setText(SHOW_VIDEO_SCREEN_TEXT);
this->addButtonToListView(mShowVideoScreen, listView);
}
示例11: selectedItemEvent
// ListView触摸监听
void TujiLayer::selectedItemEvent(Ref* pSender, ListViewEventType type)//ListView触摸事件
{
ListView* listView = static_cast<ListView*>(pSender);
CC_UNUSED_PARAM(listView);
// if (m_iBeforeSel == listView->getCurSelectedIndex())
// {
// return;
// }
// String *normalBtn = String::createWithFormat("Cell_%d.png", m_iBeforeSel);
// String *SelctBtn = String::createWithFormat("CellSel_%d.png", listView->getCurSelectedIndex());
m_iBeforeSel = listView->getCurSelectedIndex();
switch (m_iBeforeSel)
{
case 0:
m_pMZ_Pic->setVisible(true);
m_pMZ_Txt->setVisible(true);
m_pMZLabel->setVisible(true);
m_pLion_Pic->setVisible(false);
m_pLionLabel->setVisible(false);
m_pStone_Pic->setVisible(false);
m_pStoneLabel->setVisible(false);
break;
case 1:
m_pMZ_Pic->setVisible(false);
m_pMZLabel->setVisible(false);
m_pMZ_Txt->setVisible(false);
m_pLionLabel->setVisible(true);
m_pLion_Pic->setVisible(true);
m_pStoneLabel->setVisible(false);
m_pStone_Pic->setVisible(false);
break;
case 2:
m_pMZ_Pic->setVisible(false);
m_pMZ_Txt->setVisible(false);
m_pMZLabel->setVisible(false);
m_pLion_Pic->setVisible(false);
m_pLionLabel->setVisible(false);
m_pStone_Pic->setVisible(true);
m_pStoneLabel->setVisible(true);
break;
case 3:
m_pMZ_Pic->setVisible(false);
m_pMZ_Txt->setVisible(false);
m_pLion_Pic->setVisible(false);
m_pStone_Pic->setVisible(false);
m_pLionLabel->setVisible(false);
m_pStoneLabel->setVisible(false);
m_pMZLabel->setVisible(false);
break;
default:
break;
}
}
示例12: main
int main(int argc, char **argv)
{
QApplication app(argc,argv);
ListView *window = new ListView();
app.setMainWidget(window);
window->show();
return app.exec();
}
示例13: onListSelectionChanged
void MainMenu::onListSelectionChanged(const QVariantList indexPath) {
if (sender()) {
ListView* menuList = dynamic_cast<ListView*>(sender());
DataModel* menuModel = menuList->dataModel();
QVariantMap map = menuModel->data(indexPath).toMap();
if (map["itemName"].canConvert(QVariant::String)) {
QString item = map["itemName"].toString();
qDebug() << "XXXX selected item name=" << item;
if (item.compare("item_read") == 0) {
qDebug() << "XXXX Read Tag was selected!";
StateManager* state_mgr = StateManager::getInstance();
state_mgr->setEventLogShowing(true);
_eventLog->setMessage("Bring a tag close");
emit read_selected();
} else if (item.compare("item_uri") == 0) {
qDebug() << "XXXX Write URI was selected!";
emit write_uri();
} else if (item.compare("item_sp") == 0) {
qDebug() << "XXXX Write SP was selected!";
emit write_sp();
} else if (item.compare("item_text") == 0) {
qDebug() << "XXXX Write Text was selected!";
emit write_text();
} else if (item.compare("item_custom") == 0) {
qDebug() << "XXXX Write Custom was selected!";
emit write_custom();
} else if (item.compare("item_about") == 0) {
qDebug() << "XXXX About was selected!";
emit about_selected();
} else if (item.compare("item_snep_vcard") == 0) {
qDebug() << "XXXX Send vCard (SNEP) was selected!";
emit send_vcard_selected();
} else if (item.compare("item_emulate_tag") == 0) {
qDebug() << "XXXX Emulate Tag was selected!";
emit emulate_tag_selected();
} else if (item.compare("item_iso7816") == 0) {
qDebug() << "XXXX ISO7816 APDU was selected!";
StateManager* state_mgr = StateManager::getInstance();
state_mgr->setEventLogShowing(true);
emit iso7816_selected();
}
}
}
}
示例14: tr
void
ReportList::slotView()
{
ListView* list = (ListView*)_stack->visibleWidget();
if (list == NULL) return;
ListViewItem* item = list->currentItem();
if (item == NULL) return;
QApplication::setOverrideCursor(waitCursor);
qApp->processEvents();
QString fileName = item->extra[0].toString();
QString filePath;
if (!_quasar->resourceFetch("reports", fileName, filePath)) {
QApplication::restoreOverrideCursor();
QString message = tr("Error fetching report '%1'").arg(fileName);
qApp->beep();
QMessageBox::critical(this, tr("Error"), message);
return;
}
ReportDefn report;
if (!report.load(filePath)) {
QApplication::restoreOverrideCursor();
QString message = tr("Report '%1' is invalid").arg(fileName);
qApp->beep();
QMessageBox::critical(this, tr("Error"), message);
return;
}
QApplication::restoreOverrideCursor();
ParamMap params;
if (!report.getParams(this, params))
return;
QApplication::setOverrideCursor(waitCursor);
qApp->processEvents();
ReportOutput* output = new ReportOutput();
if (!report.generate(params, *output)) {
QApplication::restoreOverrideCursor();
delete output;
QString message = tr("Report '%1' failed").arg(fileName);
qApp->beep();
QMessageBox::critical(this, tr("Error"), message);
return;
}
QApplication::restoreOverrideCursor();
ReportViewer* view = new ReportViewer(report, params, output);
view->show();
}
示例15: ListView
ListView* ListView::create()
{
ListView* widget = new ListView();
if (widget && widget->init())
{
widget->autorelease();
return widget;
}
CC_SAFE_DELETE(widget);
return nullptr;
}