Results 1 to 15 of 15

Thread: Stupid list widget won't clear

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2007
    Location
    India/Bangalore
    Posts
    156
    Thanks
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Thumbs up Re: Stupid list widget won't clear

    I faced Same problem, actual problem in currentRowChanged() signal's slot

    I have taken one slot for currentRowChanged() signal of listwidget there i am trying to access element like following code, if we clear the list that time also that slot will be get called,so memory crash occurs,

    My old code,

    connect(myistWidget,SIGNAL(currentRowChanged(int)) ,this,SLOT(changeLabel(int)));

    void QZugNummerDlgAction::changeLabel(int position)
    {
    QString labelText = myistWidget.at(position);//if we clear list memory crash occurs heremyLabel->setText(labelText);
    }

    New Code, i put the following condition it works properly,

    void QZugNummerDlgAction::changeLabel(int position)
    {
    if(myistWidget->currentRow()!=-1)
    {
    QString labelText = myistWidget.at(position);
    myLabel->setText(labelText);
    }
    }


    Thanks,
    Rajesh.S

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Stupid list widget won't clear

    Quote Originally Posted by rajeshs View Post
    QString labelText = myistWidget.at(position);//if we clear list memory crash occurs here
    This shouldn't even compile, as "myistWidget" is a pointer.

    What is that "at" method? QListWidget doesn't have such method.

  3. #3
    Join Date
    Jun 2007
    Location
    India/Bangalore
    Posts
    156
    Thanks
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Thumbs up Re: Stupid list widget won't clear

    Sorry ,one mistake in my code

    That is not listwidget, there i am taking one corresponding
    Qlist so if we access -1 position from QList crash occurs,

    that line is myqlist->at(position).

    Thanks,
    Rajesh.S

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Stupid list widget won't clear

    Quote Originally Posted by rajeshs View Post
    That is not listwidget, there i am taking one corresponding
    Qlist so if we access -1 position from QList crash occurs,
    OK, that explains everything. Qt docs warn about accessing inexistent items.

Similar Threads

  1. Replies: 8
    Last Post: 1st October 2015, 07:23
  2. Controlling which widget on top layer?
    By JonathanForQT4 in forum Qt Programming
    Replies: 6
    Last Post: 22nd March 2007, 14:27
  3. Replies: 4
    Last Post: 10th March 2007, 18:01
  4. Custom widget in list view
    By fusoin23 in forum Qt Programming
    Replies: 1
    Last Post: 18th November 2006, 14:09
  5. [Qt 4.1.0] Split a widget on demand
    By Townk in forum Qt Programming
    Replies: 3
    Last Post: 17th February 2006, 14:16

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.