Sinis
2011-03-04 03:08:32 UTC
I need MList to show a two level tree model, I append the code to the mail and show some part of the code below, if there is any help:
class ListCellCreator : public MAbstractCellCreator<MContentItem> {
public:
ListCellCreator();
void updateCell(const QModelIndex & index, MWidget * cell) const;
};
...
void ListCellCreator::updateCell(const QModelIndex & index, MWidget * cell) const {
if (!index.isValid() || !cell) return;
MContentItem * item = qobject_cast<MContentItem *>(cell);
QVariant data = index.data(Qt::DisplayRole);
item->setSubtitle(data.value<QString>());
}
...
void ListPage::createContent()
{
MApplicationPage::createContent();
MLayout * layout = new MLayout(centralWidget());
MLinearLayoutPolicy * policy = new MLinearLayoutPolicy(layout, Qt::Vertical);
MList * list = new MList;
list->setShowGroups(true);
ListCellCreator * creator = new ListCellCreator;
list->setCellCreator(creator);
ListHeaderCreator * headerCreator = new ListHeaderCreator;
list->setHeaderCreator(headerCreator);
list->setItemModel(createModel());
policy->addItem(list);
layout->setPolicy(policy);
centralWidget()->setLayout(layout);
QObject::connect(list, SIGNAL(itemClicked(const QModelIndex &)), this, SLOT(clicked(const QModelIndex &)));
}
...
void ListPage::clicked(const QModelIndex & index) {
Q_ASSERT(0);
//test
}
I run the code in meego emulator, it shows MList. I click list item, but ListPage::clicked(const QModelIndex & index) is not be executed, and i enter DEBUG mode and follow the code with the same result.
PS:I know meegotouch widgetsgallery litter, where could i find more information about meegotouch widgetsgallery
------------------ ÔÊŒÓÊŒþ ------------------
·¢ŒþÈË: "stanislav.ionascu"<***@nokia.com>;
·¢ËÍʱŒä: 2011Äê3ÔÂ4ÈÕ(ÐÇÆÚÎå) Á賿2:45
ÊÕŒþÈË: "sinis"<***@foxmail.com>;
³ËÍ: "meego-touch-dev"<meego-touch-***@meego.com>;
Ö÷Ìâ: Re: Re£º [MeeGo-touch-dev] problem about signal itemClicked in MLIST
If the widget, in this case MContentItem, has the clicked signal, it should just work.
Could you share the part of the code which creates the list cells (The ListCellCreator class). And how do you check if the signal is emitted or not?
Does the meegotouch widgetsgallery list page (Lists, Grids and Popups - > List) work for you? When clicking on the item it should output "item row number #n clicked", if it works.
Thanks.
Best Regards,
Stanislav Ionascu.
class ListCellCreator : public MAbstractCellCreator<MContentItem> {
public:
ListCellCreator();
void updateCell(const QModelIndex & index, MWidget * cell) const;
};
...
void ListCellCreator::updateCell(const QModelIndex & index, MWidget * cell) const {
if (!index.isValid() || !cell) return;
MContentItem * item = qobject_cast<MContentItem *>(cell);
QVariant data = index.data(Qt::DisplayRole);
item->setSubtitle(data.value<QString>());
}
...
void ListPage::createContent()
{
MApplicationPage::createContent();
MLayout * layout = new MLayout(centralWidget());
MLinearLayoutPolicy * policy = new MLinearLayoutPolicy(layout, Qt::Vertical);
MList * list = new MList;
list->setShowGroups(true);
ListCellCreator * creator = new ListCellCreator;
list->setCellCreator(creator);
ListHeaderCreator * headerCreator = new ListHeaderCreator;
list->setHeaderCreator(headerCreator);
list->setItemModel(createModel());
policy->addItem(list);
layout->setPolicy(policy);
centralWidget()->setLayout(layout);
QObject::connect(list, SIGNAL(itemClicked(const QModelIndex &)), this, SLOT(clicked(const QModelIndex &)));
}
...
void ListPage::clicked(const QModelIndex & index) {
Q_ASSERT(0);
//test
}
I run the code in meego emulator, it shows MList. I click list item, but ListPage::clicked(const QModelIndex & index) is not be executed, and i enter DEBUG mode and follow the code with the same result.
PS:I know meegotouch widgetsgallery litter, where could i find more information about meegotouch widgetsgallery
------------------ ÔÊŒÓÊŒþ ------------------
·¢ŒþÈË: "stanislav.ionascu"<***@nokia.com>;
·¢ËÍʱŒä: 2011Äê3ÔÂ4ÈÕ(ÐÇÆÚÎå) Á賿2:45
ÊÕŒþÈË: "sinis"<***@foxmail.com>;
³ËÍ: "meego-touch-dev"<meego-touch-***@meego.com>;
Ö÷Ìâ: Re: Re£º [MeeGo-touch-dev] problem about signal itemClicked in MLIST
If the widget, in this case MContentItem, has the clicked signal, it should just work.
Could you share the part of the code which creates the list cells (The ListCellCreator class). And how do you check if the signal is emitted or not?
Does the meegotouch widgetsgallery list page (Lists, Grids and Popups - > List) work for you? When clicking on the item it should output "item row number #n clicked", if it works.
Thanks.
Best Regards,
Stanislav Ionascu.
Thanks for your explanation.
But i have a litter puzzled, my ListCellCreator inherits MAbstractCellCreator<MContentItem> and create widget MContentItem,
MContentItem have a "clicked()" signal, however, i still fail to emit an "itemClicked" signal. When i clicked mlist,
i can received a "clicked()" signal from some MContentItem instead of an "itemClicked" signal from mlist.
------------------ ÔÊŒÓÊŒþ ------------------
·¢ËÍʱŒä: 2011Äê3ÔÂ3ÈÕ(ÐÇÆÚËÄ) ÏÂÎç5:50
Ö÷Ìâ: Re: [MeeGo-touch-dev] problem about signal itemClicked in MLIST
Hi,
For MList to emit an itemClicked signal, your widgets, which are created
in ListCellCreator, must have a "clicked()" signal.
The itemClicked signals for the headers will not be emitted.
Best Regards,
Stanislav Ionascu.
But i have a litter puzzled, my ListCellCreator inherits MAbstractCellCreator<MContentItem> and create widget MContentItem,
MContentItem have a "clicked()" signal, however, i still fail to emit an "itemClicked" signal. When i clicked mlist,
i can received a "clicked()" signal from some MContentItem instead of an "itemClicked" signal from mlist.
------------------ ÔÊŒÓÊŒþ ------------------
·¢ËÍʱŒä: 2011Äê3ÔÂ3ÈÕ(ÐÇÆÚËÄ) ÏÂÎç5:50
Ö÷Ìâ: Re: [MeeGo-touch-dev] problem about signal itemClicked in MLIST
Hi,
For MList to emit an itemClicked signal, your widgets, which are created
in ListCellCreator, must have a "clicked()" signal.
The itemClicked signals for the headers will not be emitted.
Best Regards,
Stanislav Ionascu.
When i clicked mlist, i find out the signal itemClicked(const
QModelIndex &) would not be emitted.
...
MList * list = new MList;
list->setShowGroup(true);
ListCellCreator * cellCreator = new ListCellCreator ;
list->setCellCreator(cellCreator);
HeaderCellCreator * headerCreator = new HeaderCellCreator ;
list->setHeaderCreator(headerCreator);
list->setModel(model);
connect(list, SIGNAL(itemClicked(const QModelIndex &), this,
SLOT(clickItem(const QModelIndex &)));
...
i code like this, after doing test, when i clicked mlist,
i find signal itemClicked(const QModelIndex &) will not be emitted,
but the signal in widgets created by ListCellCreator
or HeaderCellCreator can be emitted,
what should i do to get the signal emitted by Mlist instead of
widgets from ListCellCreator or HeaderCellCreator.
Any suggestions are greatly appreciated
Thanks
_______________________________________________
MeeGo-touch-dev mailing list
http://lists.meego.com/listinfo/meego-touch-dev
QModelIndex &) would not be emitted.
...
MList * list = new MList;
list->setShowGroup(true);
ListCellCreator * cellCreator = new ListCellCreator ;
list->setCellCreator(cellCreator);
HeaderCellCreator * headerCreator = new HeaderCellCreator ;
list->setHeaderCreator(headerCreator);
list->setModel(model);
connect(list, SIGNAL(itemClicked(const QModelIndex &), this,
SLOT(clickItem(const QModelIndex &)));
...
i code like this, after doing test, when i clicked mlist,
i find signal itemClicked(const QModelIndex &) will not be emitted,
but the signal in widgets created by ListCellCreator
or HeaderCellCreator can be emitted,
what should i do to get the signal emitted by Mlist instead of
widgets from ListCellCreator or HeaderCellCreator.
Any suggestions are greatly appreciated
Thanks
_______________________________________________
MeeGo-touch-dev mailing list
http://lists.meego.com/listinfo/meego-touch-dev