Page 2 of 2 FirstFirst 12
Results 21 to 25 of 25

Thread: Is it possible to dynamically populate a ListView within a GridView ?

  1. #21
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Is it possible to dynamically populate a ListView within a GridView ?

    Ok, strange.

    Can you try to create a minimal example that can be built and run and shows the problem?

    Cheers,
    _

  2. #22
    Join Date
    Mar 2016
    Posts
    12
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Is it possible to dynamically populate a ListView within a GridView ?

    Sorry for the late reply but I haven't got the time until now.

    I made this little example which build and run but with the same problem.

    ListViewExample.zip

    I hope it helps to understand the issue.

  3. #23
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Is it possible to dynamically populate a ListView within a GridView ?

    Ok, this is more complicated than I thought

    I found two things that work:
    - make the channels property a QList<QObject*>
    - Use a QAbstractListModel derived class to provide the channel data

    Some other observations:
    - main.cpp cannot compile because there is no MainWindow.h, it is mainwindow.h
    - this can be written much shorter. Instead of
    Qt Code:
    1. QString::fromStdString("channel " + QString::number(i).toStdString()).toStdString().c_str())
    To copy to clipboard, switch view to plain text mode 
    write this
    Qt Code:
    1. QString("channel %1").arg(i);
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

  4. The following user says thank you to anda_skoa for this useful post:

    andrioli.n (14th March 2016)

  5. #24
    Join Date
    Mar 2016
    Posts
    12
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Is it possible to dynamically populate a ListView within a GridView ?

    Quote Originally Posted by anda_skoa View Post
    Ok, this is more complicated than I thought

    I found two things that work:
    - make the channels property a QList<QObject*>
    - Use a QAbstractListModel derived class to provide the channel data

    Some other observations:
    - main.cpp cannot compile because there is no MainWindow.h, it is mainwindow.h
    - this can be written much shorter. Instead of
    Qt Code:
    1. QString::fromStdString("channel " + QString::number(i).toStdString()).toStdString().c_str())
    To copy to clipboard, switch view to plain text mode 
    write this
    Qt Code:
    1. QString("channel %1").arg(i);
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _
    I use your first suggestion and it worked perfectly.

    Your tip for QString is a good-to-know one ;-)

    For the mainwindow include, you are right but it was compiling on my setup (which is weird...).

    Thank you for the help !

  6. #25
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Is it possible to dynamically populate a ListView within a GridView ?

    Quote Originally Posted by andrioli.n View Post
    For the mainwindow include, you are right but it was compiling on my setup (which is weird...).
    You were likely building on Windows or OSX with a case-insensitve file system.

    Cheers,
    _

Similar Threads

  1. Replies: 0
    Last Post: 16th October 2015, 17:51
  2. GridView without reflow
    By shaolin in forum Qt Quick
    Replies: 15
    Last Post: 12th May 2014, 15:14
  3. Replies: 7
    Last Post: 9th September 2013, 09:31
  4. Usage of QTableView as gridview
    By ada10 in forum Newbie
    Replies: 7
    Last Post: 10th August 2010, 00:13
  5. Replies: 1
    Last Post: 14th October 2007, 11:09

Tags for this Thread

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.