Results 1 to 20 of 22

Thread: Display Problem

Hybrid View

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

    Default Display Problem

    Hi


    I added the frame within list view.......


    It is showing the of sutput fraction oeconds and closed the window automatically....

    I created one frame class called Tweet. There i used to display the image,some text..

    In output it showing show only frame,not showed the image,text..... frame also showing fraction of seconds and automatically closed the window.....code
    Qt Code:


    Qt Code:
    1. Tweet *tweet;
    2. setVisible(this)
    3. ui->listView->setIndexWidget(item(0)->index() , tweet );
    4. ui->listView->setUpdatesEnabled( true );
    To copy to clipboard, switch view to plain text mode 

    if i change the tweet width to listview width ,it also not changing....

    Qt Code:
    1. tweet->resize( ui->listView->width() , tweet->height() );
    To copy to clipboard, switch view to plain text mode 

    please help me


    Thanks

    Yuva R
    Last edited by jpn; 1st May 2009 at 12:19. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Display Problem

    Hey, how often do you need to be told, to don't multiple post an issue? And further please learn the basics of C++!

    It is showing nothing because it's an empty pointer! use
    Qt Code:
    1. Tweet *tweet = new Tweet();
    To copy to clipboard, switch view to plain text mode 
    And wasn't you told to better not use QListView? May it is better to use QListWidget.

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

    Default Re: Display Problem

    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
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: Display Problem

    Thanks for your replies....

    I am learning the c++.

    Here I used the list widget...

    I need 20 rows ....

    still it is not displaying the my frame within listwidget
    Qt Code:
    1. Tweet *tweet = new Tweet(this);
    2. for (int i = 0; i < 20; i++ ) {
    3. ui->listWigdet->setIndexWidget(item(i)->index(),tweet);
    4. }
    To copy to clipboard, switch view to plain text mode 

    please find my Tweet class code in attachment...

    please help me
    Attached Files Attached Files

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

    Default Re: Display Problem

    there is nothing helpful in those files you attached. And they are usind some .ui file which is not attached, and where all the gui is. Can you just attach your files? Files where you want to use that Tweet? For example what the item(int index) function come from?

    I am learning the c++.
    So learn it a little bit more on some simple examples and then try something more complex. Because we see you have a lack of basic C++ knowledge even with very simple C++ statements, so we can paste some working code for you but you will not understand major part of it! without a proper C++ knowledge...
    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. #6
    Join Date
    Apr 2009
    Posts
    61
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: Display Problem

    Thanks for your reply....

    I will continue my learning with complex examples of c++.

    Here i have attached the files....


    please help me
    Attached Files Attached Files

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

    Default Re: Display Problem

    first of all this is quite weird to me (I'd rather use QStandardItemModel as member variable):
    Qt Code:
    1. class MainWindow : public QMainWindow, QStandardItemModel
    To copy to clipboard, switch view to plain text mode 
    but this way it can maybe work too... But:
    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent)
    2. : QMainWindow(parent), ui(new Ui::MainWindowClass)
    3. {
    4. ui->setupUi(this);
    5. setVisible(true); // 1
    6. qDebug() << " list view";
    7. Tweet *tweet = new Tweet(); // 2
    8. for (int i = 0; i < 24; i++ ) {
    9. tweet->resize( ui->listWidget->width() , tweet->height() );
    10. item(i)->setSizeHint(tweet->size()); // 3
    11. ui->listWidget->setIndexWidget(item(i)->index(),tweet); // 4
    12. }
    13. }
    To copy to clipboard, switch view to plain text mode 
    this constructor it's problem in your case. And your problem is not that it's not showing frame, but it's crashing because of segmentation fault!. And segmentation fault is commonly the error caused by bad code - means you can't write it in way it can work (and it is n C and C++, Qt don't do seg faults by itself) - back to the old story - learn some C++...
    But ok, I can explain your errors.
    In line marked as "// 1" you are calling setVisible(true); it's not an error maube but you are also calling show in main() finction which shows your main window - and that the way it should be, so just delete that line.
    In line marked as "// 2" - you created a Tweet, but it's just one Tweet. You want to have 24 same Tweets in list?
    Ok, and now you start for loop. Tell me how many items is in your model at the start of the for loop? Don't guess. You can check it easily. You don't event have to check it. Just think for a moment and please post how many items is in your model at the start of the for loop? And wysota asked you for it once and it was few days ago so maybe you found any way to do that in those days.
    When you found the answer, then try to tell me what happens in line marked as "// 3".
    If it's to difficult for you to open the Assistant (usually typing "assistant" in run command window (shortcut: WinLogo + R) is enough to run it) and searching there something about QStandardItemModel you can just click on this link: QStandardItemModel::item() and read the only sentence there about that method.
    Finally, tell me also how many time the line "// 4" is reached/executed in your application?
    Good luck in answers searching!
    Last edited by faldzip; 2nd May 2009 at 10:24.
    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.

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

    yuvaraj.yadav (2nd May 2009)

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

    Default Re: Display Problem

    Hi

    Thanks for your reply...


    if delete the SetVisible (true) line ....... Simple my project is executed and nothing it showed ,even mainwindow too.

    Here

    My point of view

    i need 24 items (rows)

    My loop execute execute //line4 24 times, so i get 24 rows of tweets


    If you don't mistake me can you provide me sample code...

    It help for me to analyze and referring purpose...

    I am struggling this issue last one week.

    Thanks

    Yuvaraj

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

    Default Re: Display Problem

    In line 3 i am going to set every Item(row) width asequal as tweet resized width

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

    Default Re: Display Problem

    i need 24 items (rows)

    My loop execute execute //line4 24 times, so i get 24 rows of tweets
    Wrong.
    Your line "// 4" is executed exactly 0 times. Why? because your app crashes one line earlier, because:
    Your model contains exactly 0 items.
    What you trying then is to set size hint in 24 items but they don't exist. Where are you creating items? I answer for you this time: there is NO LINE of code in your app where you create item. So if you would take a look into docs and see what QStandardItemModel::item() method does, you would see that it returns 0 in your case, bacause there are no items at all. And how do you imagine setting size hint to NULL pointer?
    You have to insert items to the model first, and then you can access items by item() method.
    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
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    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.

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.