Results 1 to 4 of 4

Thread: QTreeView clicked signal coordinates

  1. #1
    Join Date
    Feb 2011
    Location
    Poland
    Posts
    12
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default QTreeView clicked signal coordinates

    It is my first post in this forum so I would like to say hello to all Qt programmers.
    Hello

    Could anyone help me in following problem:
    I would like to receive coordinates of QTreeView clicked signal.
    I need them because action performed on item displayed in tree view will depend of where this item was clicked. clicked signal is called with QModelIndex argument and I couldn't find any coordinate related info.

    Application is developed for Symbian devices.
    Thank you in advance

  2. #2
    Join Date
    Jan 2011
    Location
    Gordion
    Posts
    52
    Thanks
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTreeView clicked signal coordinates

    in your header write a slot like
    Qt Code:
    1. void treeViewClickProgress();
    To copy to clipboard, switch view to plain text mode 
    after in your source code in mainwindows calling state
    Qt Code:
    1. QObject::connect(treeview,SIGNAL(Clicked),this,SLOT(treeViewClickProgress()));
    To copy to clipboard, switch view to plain text mode 

    and at last write a void function like this;

    Qt Code:
    1. void MainWindow::treeViewClickProgress()
    2.  
    3. {
    4. int rowNum = ui->treeView->selectionModel()->currentIndex().row();
    5. int colNum= ui->treeView->selectionModel()->currentIndex().column();
    6. qDebug() << rowNum << colNum;
    7. }
    To copy to clipboard, switch view to plain text mode 

    hope this help...
    edit...
    dont copy paste, thats pseudo code only..

  3. #3
    Join Date
    Feb 2011
    Location
    Poland
    Posts
    12
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Re: QTreeView clicked signal coordinates

    Thank you for your anwser.

    I was thinking about X and Y coordinates of point which user touched on screen, but separating one column into many columns maybe a right solution.
    I have to check it...

  4. #4
    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: QTreeView clicked signal coordinates

    Reimplement the QAbstractItemDelegate::editorEvent() for your view's delegate (you'll have to provide one). There you can get all the coordinates you want. Signals and slots is a more high level mechanism which is not suited for what you want.
    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.


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

    michalk (2nd February 2011)

Similar Threads

  1. Replies: 0
    Last Post: 30th September 2010, 15:11
  2. Replies: 0
    Last Post: 26th August 2010, 16:25
  3. Replies: 1
    Last Post: 23rd January 2010, 22:04
  4. signal mapping on pushbutton signal clicked
    By wagmare in forum Qt Programming
    Replies: 2
    Last Post: 17th March 2009, 07:54
  5. Emit clicked( QModelIndex &) from a QTreeView?
    By Ran in forum Qt Programming
    Replies: 1
    Last Post: 15th December 2008, 04:42

Tags for this Thread

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.