Results 1 to 5 of 5

Thread: [SOLVED] How do I deselect all items in a model/view without emit a signal?

  1. #1
    Join Date
    May 2006
    Location
    Stockholm, Sweden
    Posts
    81
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default [SOLVED] How do I deselect all items in a model/view without emit a signal?

    Hi!

    I have looked around the forum and can't find any topics about this, so either its simple to do it or I have missed it...

    I have a QTreeView and a custom model and want to deselect all items in the view without emitting a signal. The reason for this is that I have slots reacting to the signals of
    changes in the selection ( QitemSelectionModel::selectionChanged(selected,des electted) ) which mess things upp when I use QTreeView::clearSelection().

    I've also tried QItemSelectionModel::reset(), but I can't make it do anything. The view doesn't change and there doesn't seem like anything is deselected...

    /pir

  2. #2
    Join Date
    May 2006
    Posts
    55
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How do I deselect all items in a model/view without emit a signal?

    Why not just set a flag, call the deselection method you found and then reset the flag ?
    In your slots you react or not according to the flag.

  3. #3
    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: How do I deselect all items in a model/view without emit a signal?

    You can temporarily block signals:
    bool QObject::blockSignals ( bool block )
    J-P Nurmi

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

    pir (21st May 2006)

  5. #4
    Join Date
    May 2006
    Location
    Stockholm, Sweden
    Posts
    81
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: How do I deselect all items in a model/view without emit a signal?

    Thanks for the tips!

    Currently I have a flag as the suggested. That works fine, but because I am so slobby it is verfy likely that I will forget about it and will cause problems in the future.

    The block thing... is there any drawbacks with using that? It seems like a very nice way to handle problems like this. It can be a problem if there are more than one flag to check and update, so blocking signals seems like a nice way to avoid them.

    One more thing, how do I set this topic as solved? I've seen that some topics have a [SOLVED] label when the author of the question have got answers that is sufficient for solving the problem.

    thanks
    /pir

  6. #5
    Join Date
    Feb 2006
    Location
    USA
    Posts
    142
    Thanks
    24
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: How do I deselect all items in a model/view without emit a signal?

    Just edit your original post's title and put [SOLVED] into it
    Life without passion is death in disguise

Similar Threads

  1. pthread instead QThread
    By brevleq in forum Qt Programming
    Replies: 8
    Last Post: 23rd December 2008, 07:16
  2. Connection of custon signals/slots
    By brevleq in forum Qt Programming
    Replies: 2
    Last Post: 23rd December 2008, 07:04

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.