Results 1 to 4 of 4

Thread: Slot "columnsMoved" is not firing?

  1. #1
    Join Date
    Nov 2009
    Location
    US, Midwest
    Posts
    215
    Thanks
    62
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Slot "columnsMoved" is not firing?

    I have a QAbstractTableModel-derived model attached to a QTreeView and I need to be able to track user movement of columns in the view. Luckily QAbstractTableModel has a signal "columnsMoved".
    So, I do usual stuff:
    Qt Code:
    1. ui.lstPairs->setModel(&_model);
    2. bool res1 = connect(&_model, SIGNAL(columnsMoved(const QModelIndex&, int, int, const QModelIndex&, int)),
    3. this, SLOT(columnsMoved(const QModelIndex&, int, int, const QModelIndex&, int)));
    4. if (!res1)
    5. return;
    To copy to clipboard, switch view to plain text mode 
    ..
    and slot implementation:
    private slots:
    void columnsMoved(const QModelIndex & sourceParent, int sourceStart, int sourceEnd, const QModelIndex & destinationParent, int destinationColumn);
    ..
    Qt Code:
    1. void viewPairs::columnsMoved(const QModelIndex & sourceParent, int sourceStart, int sourceEnd, const QModelIndex & destinationParent, int destinationColumn)
    2. {
    3. int i =5; // test
    4. }
    To copy to clipboard, switch view to plain text mode 

    When I run it in debug the res1 variable is TRUE, so everything looks normal. Then I start moving the view columns using mouse and my slot is never called. (I place a breakpoint in int i = 5; line)

    Question: what can be the problem that causes columnsMoved slot to never be called?
    Thanks.
    Last edited by TorAn; 6th November 2014 at 14:52.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Slot "columnsMoved" is not firing?

    Moving columns in the view does not cause them to be moved in the model.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    TorAn (6th November 2014)

  4. #3
    Join Date
    Nov 2009
    Location
    US, Midwest
    Posts
    215
    Thanks
    62
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Slot "columnsMoved" is not firing?

    Oh, I see! I missed that one in the documentation. It states there that "This signal is emitted after columns have been moved within the model.". Then my question is perhaps simpler:

    How to detect an event when user moves columns in the view, for example by doing mouse drag of forth column in front of the second and so forth...

    Thanks.

  5. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Slot "columnsMoved" is not firing?

    The horizontal QHeaderView emits signals when columns are moved.
    QHeaderView::sectionMoved()

Similar Threads

  1. Replies: 5
    Last Post: 24th May 2010, 21:20
  2. debugging "signal does not reach slot" in a template class
    By Daniel Dekkers in forum Qt Programming
    Replies: 1
    Last Post: 3rd April 2010, 16:03
  3. Replies: 1
    Last Post: 5th January 2010, 13:34
  4. Replies: 1
    Last Post: 23rd August 2008, 22:09
  5. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:05

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.