Results 1 to 5 of 5

Thread: QTableView currentChanged <> selecting header

  1. #1
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    99
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default QTableView currentChanged <> selecting header <SOLVED>

    Hi,

    I'm experimenting a little with QTableViews selection behaviour.
    The default is when you click on an item it gets selected (blue), but editing doesn't start yet. When you click on a column , the entire column gets selected (blue).

    If you alter the editTrigger property for the view to CurrentChanged, then clicking on a cell starts editing immediately. Ok that's what I want.

    But when you click a vertical header now, the first cell is in editing state (the delegate shows up) and that is not what I want.

    Does anyone know a simple way to use the currentChanged property without getting the first cell in editing state when clicking on a header?



    You can see this behaviour yourself if you want:
    in the relationaltablemodel example I added a line to the createview function

    Qt Code:
    1. QTableView *createView(const QString &title, QSqlTableModel *model)
    2. {
    3. QTableView *view = new QTableView;
    4. ...
    5. view->setEditTriggers ( QAbstractItemView::CurrentChanged );
    6. return view;
    7. }
    To copy to clipboard, switch view to plain text mode 

    Maybe i'm not seeing the obvious...
    All suggestions are welcome
    Last edited by Everall; 6th February 2006 at 08:16.

  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: QTableView currentChanged <> selecting header

    You can remove the trigger and try:
    Qt Code:
    1. connect(myTableView,
    2. SIGNAL(activated(const QModelIndex &)),
    3. myTableView,
    4. SLOT(edit(const QModelIndex &))
    5. );
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    99
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QTableView currentChanged <> selecting header <SOLVED>

    Thanks Wysota,

    for the suggestion. It certainly helped looking at it from another angle. I would never have thought about that.

    I tried it with signal activated, but that didn't work. But signal clicked did the job

    Qt Code:
    1. connect(myTableView,
    2. SIGNAL(clicked(const QModelIndex &)),
    3. myTableView,
    4. SLOT(edit(const QModelIndex &))
    5. );
    To copy to clipboard, switch view to plain text mode 

    Thanks a lot

    Everall
    Last edited by Everall; 6th February 2006 at 08:13.

  4. #4
    Join Date
    Jun 2008
    Posts
    89
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QTableView currentChanged <> selecting header

    I have a similar problem...

    I need to start editing when i click on any cell in the QTableView.
    I have tried setting editTriggers::Currentchanged property to 1. and also with the code
    Qt Code:
    1. connect(myTableView,
    2. SIGNAL(clicked(const QModelIndex &)),
    3. myTableView,
    4. SLOT(edit(const QModelIndex &))
    5. );
    To copy to clipboard, switch view to plain text mode 

    but the issue is that the contents of the cell get selected, when i click on the cell.
    I just want editing without selection of contents ans when i double click on the cell the content get selected.

    Please help....
    GK

  5. #5
    Join Date
    Jun 2008
    Posts
    89
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Removing selection from QTableView Cell

    I have a similar problem...

    I need to start editing when i click on any cell in the QTableView.
    I have tried setting editTriggers::Currentchanged property to 1. and also with the code

    Qt Code:
    1. connect(myTableView,
    2. SIGNAL(clicked(const QModelIndex &)),
    3. myTableView,
    4. SLOT(edit(const QModelIndex &))
    5. );
    To copy to clipboard, switch view to plain text mode 

    but the issue is that the contents of the cell get selected, when i click on the cell.
    I just want editing without selection of contents ans when i double click on the cell the content get selected.

    Please help....
    GK

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.