Results 1 to 2 of 2

Thread: Why if no TreeWidgetItem was clicked the signal itemPressed no emitt?

  1. #1
    Join Date
    Feb 2016
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Red face Why if no TreeWidgetItem was clicked the signal itemPressed no emitt?

    Hi!
    I see the document say:
    ----------------------------------------------------------------------------------------------------------------------------------------
    void QTreeWidget::itemPressed(QTreeWidgetItem * item, int column)

    This signal is emitted when the user presses a mouse button inside the widget.

    The specified item is the item that was clicked, or 0 if no item was clicked. The column is the item's column that was clicked, or -1 if no item was clicked.
    ----------------------------------------------------------------------------------------------------------------------------------------

    When I connect itemPressed to My slot void EditCurrentItem(QTreeWidgetItem* currentItem, int column):
    Qt Code:
    1. connect(m_ui.m_TreeWidget,SIGNAL(itemPressed(QTreeWidgetItem*, int)),this,SLOT(EditCurrentItem(QTreeWidgetItem*, int)));
    To copy to clipboard, switch view to plain text mode 
    if the item that was clicked the sinal will be emitted. But when I cancel click item(click on the blank space Inside the TreeWidget), no itemPressed be emit? I don't knowWhy.

    1.jpg

    2.jpg

    the SLOT void EditCurrentItem(QTreeWidgetItem* currentItem, int column) as below:
    Qt Code:
    1. void QuesManager::EditCurrentItem(QTreeWidgetItem* currentItem, int column)
    2. {
    3. if(currentItem != 0)
    4. {
    5. m_ui.m_Title->setText(currentItem->text(2));
    6. m_ui.m_Ans->setText(currentItem->text(3));
    7. }
    8. else
    9. {
    10. m_ui.m_Title->setText("");
    11. m_ui.m_Ans->setText("");
    12. }
    13. }
    To copy to clipboard, switch view to plain text mode 

    The small project had been upload to the Attachment.(My Qt version is 5.5 and using VS2010)
    Thanks help me!

    See Attachment:
    https://github.com/ljcduo/TempAns1
    Last edited by ljc123456gogo; 4th February 2016 at 05:10.

  2. #2
    Join Date
    Feb 2016
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Why if no TreeWidgetItem was clicked the signal itemPressed no emitt?

    Sloved!
    I Change itemPressed to itemSelectionChanged, It works!

    See also:
    https://forum.qt.io/topic/63779/why-...essed-no-emitt

Similar Threads

  1. Replies: 8
    Last Post: 10th July 2015, 12:12
  2. QTextEdit and URL clicked signal
    By Pablik in forum Qt Programming
    Replies: 6
    Last Post: 24th June 2012, 20:06
  3. clicked signal from QMainWindow
    By Tomasz in forum Newbie
    Replies: 3
    Last Post: 13th December 2010, 14:12
  4. signal mapping on pushbutton signal clicked
    By wagmare in forum Qt Programming
    Replies: 2
    Last Post: 17th March 2009, 07:54
  5. creating treeWidgetItem using emitted signal from thread class
    By santosh.kumar in forum Qt Programming
    Replies: 1
    Last Post: 25th June 2007, 08:37

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.