Results 1 to 7 of 7

Thread: QTableView doubleclicked event not working

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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: QTableView doubleclicked event not working

    Quote Originally Posted by sgmurphy19 View Post
    Any idea why no error occurred at compile?
    Because SIGNAL is defined this way:
    Qt Code:
    1. #define SIGNAL(a) "2"#a
    To copy to clipboard, switch view to plain text mode 
    In other words, you pass strings to connect, not methods, so compiler can't check them. Although such errors can be detected at runtime, if you compile your application in debug mode and look at the console.

  2. #2
    Join Date
    Sep 2008
    Posts
    17
    Qt products
    Qt4
    Platforms
    Windows

    Smile Re: QTableView doubleclicked event not working

    i think by default the doubleClicked signal makes the currend index to be selected in edit mode. But i am using QT 4.4 and i dont know have any idea on other versions

    You can try this

    QObject::connect(this, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(edit(const QModelIndex &)));

    I hope it will work. Once you double click in a cell it will be in edit mode but before emitting the double clicked signal (manually) you have to select the iindex by
    this->setCurrentIndex(index);

    Note: "this" is a object of QTableView. Lets see what happends

  3. #3
    Join Date
    Mar 2009
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTableView doubleclicked event not working

    I wonder if anybody can help me. I'm having a similar problem with not being able to get "doubleClicked" to work on a QTableView. I'm using Qt 4.5.0 (commercial) on Windows XP.

    I have a simple form with a QTableView. I create and set my model as follows:

    Qt Code:
    1. g_paScheduleTableModel = new AScheduleTableModel(m_paSchedule);
    2. ui.m_pqScheduleTableView->setModel( g_paScheduleTableModel );
    To copy to clipboard, switch view to plain text mode 
    I make sure the edit triggers are set and may my connections:

    Qt Code:
    1. ui.m_pqScheduleTableView->setEditTriggers(QAbstractItemView::AllEditTriggers);
    2. connect(ui.m_pqScheduleTableView, SIGNAL(clicked(const QModelIndex&)), this,
    3. SLOT(cellClicked(QModelIndex& )));
    4. connect(ui.m_pqScheduleTableView, SIGNAL(doubleClicked( const QModelIndex&)), this, SLOT(cellDoubleClicked(const QModelIndex&)));
    To copy to clipboard, switch view to plain text mode 
    I receive the signals for "clicked" but I do not receive the signals "doubleClicked".

    Any suggestions?
    Last edited by jpn; 15th March 2009 at 10:39. Reason: missing [code] tags

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.