Results 1 to 5 of 5

Thread: QListView is not showing contnet

  1. #1
    Join Date
    Jun 2008
    Posts
    6
    Thanks
    1
    Qt products
    Platforms
    Unix/X11

    Post QListView is not showing contnet

    i created QListView to show my model content like this.

    Qt Code:
    1. Play::Play( QWidget *parent, Qt::WFlags f )
    2. : QWidget( parent, f )
    3. {
    4. QContentSet contentset;
    5. contentset.addCriteria(QContentFilter::MimeType, "audio/*", QContentFilter::Or);
    6. QContentSetModel model( &contentset );
    7. listView= new QListView(this);
    8. listView->setModel( &model );
    9. vboxLayout = new QVBoxLayout(this);
    10. vboxLayout->addWidget(listView);
    11. this->setLayout(vboxLayout);
    12. this->show();
    13. }
    To copy to clipboard, switch view to plain text mode 

    i added some other components in the vboxLayout.

    but the list is not showing any content, even model(QContentSetModel) had content.
    Last edited by jpn; 20th August 2008 at 14:19. Reason: missing [code] tags

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QListView is not showing contnet

    The model goes out of scope. Allocate it with C++ operator new.
    J-P Nurmi

  3. #3
    Join Date
    Jun 2008
    Posts
    6
    Thanks
    1
    Qt products
    Platforms
    Unix/X11

    Post Re: QListView is not showing contnet

    in Qt Assistant manual he provided example:

    Qt Code:
    1. QContentSet contentset( QContentFilter::Directory, "/Documents" );
    2. QContentSetModel model( &contentset );
    3.  
    4. QListView listview( this );
    5. listview->setModel( &model );
    To copy to clipboard, switch view to plain text mode 

    i did in the same way.
    and i tried with new operation also.
    it's not working.


    Hrudhay
    Last edited by jpn; 20th August 2008 at 14:53. Reason: missing [code] tags

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QListView is not showing contnet

    The reference documentation expects basic C++ knowledge from its reader. Example snippets are kept as simple as possible for the sake of readability. Anyway, you're passing pointers to stack variables. What do you expect to happen when they go out of scope? They are both (the content set and the model) QObjects which cannot be copied.

    So, exactly the same fault applies to the content set. Once the content set goes out of scope, the model has nothing to show.
    J-P Nurmi

  5. The following user says thank you to jpn for this useful post:

    hrudhay (21st August 2008)

  6. #5
    Join Date
    Jun 2008
    Posts
    6
    Thanks
    1
    Qt products
    Platforms
    Unix/X11

    Default Re: QListView is not showing contnet

    Thanks..

    now it is working.

Similar Threads

  1. about qt/embedded widgets showing in ARM platform
    By xianshuiren in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 3rd December 2007, 05:48
  2. QListView word wrap
    By serega in forum Qt Programming
    Replies: 17
    Last Post: 30th August 2007, 03:13

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.