So i had a problem showing the right data after parsing xml. I found a way, but now i need help from u guys:
My main.cpp calls for list.cpp (here is the important part):
List
::List(bool first,
QWidget *parent
) :{
if(first == true)
{
QString str
= "http://www.forumcinemas.lv/rss/xml/movies/";
Download_xml *Other= new Download_xml(str);
this->hide();
}
else
{
layout->addWidget(listWidget);
this->setFocus();
}
List::List(bool first, QWidget *parent) :
QWidget(parent)
{
if(first == true)
{
QString str = "http://www.forumcinemas.lv/rss/xml/movies/";
Download_xml *Other= new Download_xml(str);
this->hide();
}
else
{
layout = new QVBoxLayout(this);
listWidget = new QListWidget(this);
layout->addWidget(listWidget);
this->setFocus();
}
To copy to clipboard, switch view to plain text mode
As u can see, i call for download_xml, where the xml parsing will take place.
Here is download_xml.cpp part.
void Download_xml::parseXml()
{
QVector<Movie *> movie_list;
List *list = new List(false);
...
_ml = movie_list;
list->completeList(_ml);
}
void Download_xml::parseXml()
{
QVector<Movie *> movie_list;
List *list = new List(false);
...
_ml = movie_list;
list->completeList(_ml);
}
To copy to clipboard, switch view to plain text mode
and here is the list.cpp function part:
void List::completeList(QVector<Movie *> ml)
{
QVector<Movie *> new_ml = ml;
for (int i = 0; i<new_ml.size(); i++)
{
listWidget->insertItem(i, "");
listWidget->setItemWidget(listWidget->item(i), new Custom_Widget
(new_ml[i]->name(), new_ml[i]->date(), new_ml[i]->about(), new_ml[i]->picture()));
listWidget
->item
(i
)->setSizeHint
(QSize (350,
470));
listWidget->setSpacing(1);
}
void List::completeList(QVector<Movie *> ml)
{
QVector<Movie *> new_ml = ml;
for (int i = 0; i<new_ml.size(); i++)
{
listWidget->insertItem(i, "");
listWidget->setItemWidget(listWidget->item(i), new Custom_Widget
(new_ml[i]->name(), new_ml[i]->date(), new_ml[i]->about(), new_ml[i]->picture()));
listWidget->item(i)->setSizeHint(QSize (350,470));
listWidget->setSpacing(1);
}
To copy to clipboard, switch view to plain text mode
The problem is, i can't see the list that is created after the parsing in XML takes place. I run through the debug, and i think that the list is created and even shown, but in background. In front all u can see is the first list, that is created empty.
That's why I ask your help: either to show the list, that is created after parsing in front, or help me rewrite the code in some way it would work better...
Bookmarks