Results 1 to 20 of 22

Thread: Display Problem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    4
    Thanked 140 Times in 132 Posts

    Default Re: Display Problem

    if delete the SetVisible (true) line ....... Simple my project is executed and nothing it showed ,even mainwindow too.
    Because it crashes even before MainWindow is showed.
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  2. #2
    Join Date
    Apr 2009
    Posts
    61
    Qt products
    Qt4
    Platforms
    MacOS X
    Thanks
    4

    Default Re: Display Problem

    Thanks

    Totally i confused . I referred the QArstractViewModel::item().....

    There we set the rows and columns .....Here My tweets going to set row by row according to loop....

    Already I asked you ,can you provide me one sample example ....

    or where can i get sample example ......

    Thanks

    Yuvaraj R

  3. #3
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    4
    Thanked 140 Times in 132 Posts

    Default Re: Display Problem

    Dude, you are not creating items any where.
    What are doing is that you want to get the pointer to an item:
    Qt Code:
    1. item(13);
    To copy to clipboard, switch view to plain text mode 
    this will return the pointer QStandardItem * to the item in row = 13. Then you want to assign some widget (your Twitt) to that item. How can you do this if you model is empty?
    In your code you are not inserting items to the model. You are setting size hints to item which DON'T EXIST. There is no item at row = 13. There is no item in row = 0, 1, 2, 3, 4, 5... So how do you want to set the size hint to those items? How do you want to assign widgets to those items? You are getting NULL pointer (do you know whats that? please confirm!) and you want to set size hint to this. The ONLY result of that is segmentation fault! You have to insert some items to the model! There are several ways to do that. Just take a look in QStandardItemModel docs and/or some Qt Examples & Demos - for exapmle appendRow() method would be useful. The sample code is already on your hard drive for that last week, so why you can't just check in docs how you can insert an item to the model?
    It takes less time than a week to get thorugh the examples and docs.
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  4. #4
    Join Date
    Apr 2009
    Posts
    61
    Qt products
    Qt4
    Platforms
    MacOS X
    Thanks
    4

    Default Re: Display Problem

    Thanks my Guru....


    Now I understood my mistake.......


    Here my code according to you......

    Tweet *tweet = new Tweet(this);
    QStandardItem *newItem = new QStandardItem;
    QStandardItemModel ::appendRow(newItem);
    ui->listWidget->setIndexWidget(newItem->index(),tweet);

    This one is displaying empty mainwinow only...

  5. #5
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    4
    Thanked 140 Times in 132 Posts

    Default Re: Display Problem

    okey, now you know how to put items to the QStandardItemModel.
    But... your QStandardItemModel has nothing to do with your QListWidget... Change QListWidget to QListView, and than you have to set your model to list view, so the view knows what to display.
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  6. The following user says thank you to faldzip for this useful post:

    yuvaraj.yadav (3rd May 2009)

  7. #6
    Join Date
    Apr 2009
    Posts
    61
    Qt products
    Qt4
    Platforms
    MacOS X
    Thanks
    4

    Thumbs up Re: Display Problem

    Hi

    Thanks for your reply ... Now it is displaying my frame on listview....


    Now problem is how do display the my 20 tweets in listview...

    Here i used for loop....

    But nothing happened ...

    Another one How do insertRows in listview..

    I tried with

    QStandard ItemModel :: insertRows(20,1, newItems).... nothing happened

    Here my total rows 20,counter value 1...

    please explain me using loop how do display same my 20 tweets


    please help me

    Thanks

    Yuvaraj

  8. #7
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 334 Times in 317 Posts

    Default Re: Display Problem

    Read the docs properly, they are of great help.
    From the docs -
    bool QAbstractItemModel::insertRows ( int row, int count, const QModelIndex & parent = QModelIndex() ) [virtual]
    On models that support this, inserts count rows into the model before the given row.
    and as for you, count shud be 20,,,get the point ??

  9. #8
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    4
    Thanked 140 Times in 132 Posts

    Default Re: Display Problem

    or just make the for loop and in every pass append one item to the model, get its index and set the Twitt widget for this.
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  10. #9
    Join Date
    Apr 2009
    Posts
    61
    Qt products
    Qt4
    Platforms
    MacOS X
    Thanks
    4

    Default Re: Display Problem

    Thanks for your reply...


    I didn't get you..



    for( int i =0; i<rowCount();i++)
    {
    QStandardItemModel::insertRow( i, newItem );
    view->setIndexWidget( newItem->index(), tweet );
    }

    Can you give sample code

  11. #10
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    4
    Thanked 140 Times in 132 Posts

    Default Re: Display Problem

    tell me what number you get from rowCount() at the start of the for loop?
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  12. #11
    Join Date
    Apr 2009
    Posts
    61
    Qt products
    Qt4
    Platforms
    MacOS X
    Thanks
    4

    Default Re: Display Problem

    one , am i correct..

    We can display 24 items in listview..


    please give one sample code

  13. #12
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    4
    Thanked 140 Times in 132 Posts

    Default Re: Display Problem

    okej, use this code, but first remove QStandardItemModel inheritance from mainwindow.h
    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent)
    2. : QMainWindow(parent), ui(new Ui::MainWindowClass)
    3. {
    4. ui->setupUi(this);
    5.  
    6. for (int i = 0; i < 24; ++i)
    7. {
    8. model->appendRow(item);
    9. }
    10.  
    11. ui->listView->setModel(model);
    12.  
    13. for (int i = 0; i < 24; ++i)
    14. {
    15. Tweet * t = new Tweet(this);
    16. t->resize(ui->listView->size().width(), 70);
    17. model->item(i)->setSizeHint(t->size());
    18. ui->listView->setIndexWidget(model->item(i)->index(), t);
    19. }
    20. }
    To copy to clipboard, switch view to plain text mode 

    And now take a one week free from work/school and spend it on learning C++ and reading docs. And try to do something by yourself next time - but not just guessing - just check what those methods, classes and C++ keywords and operators do! It's simple - you can just use Google (www.google.com) to find C++ tutorial (and English Lessons/Dictionaries if you can understand docs - but how you can say that if dont mind even opening single document?)
    Last edited by faldzip; 3rd May 2009 at 14:37.
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

Similar Threads

  1. Replies: 1
    Last Post: 23rd April 2009, 09:05
  2. Replies: 19
    Last Post: 3rd April 2009, 23:17
  3. Replies: 2
    Last Post: 19th November 2008, 09:01
  4. Tricky problem with ARGB widget / UpdateLayeredWindow
    By nooky59 in forum Qt Programming
    Replies: 3
    Last Post: 21st February 2008, 10:35
  5. Model display problem
    By gyre in forum Newbie
    Replies: 3
    Last Post: 31st December 2007, 13:46

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
  •  
Qt is a trademark of The Qt Company.