Results 1 to 4 of 4

Thread: getting QAction text from the slot

  1. #1
    Join Date
    Apr 2008
    Posts
    104
    Thanks
    8
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default getting QAction text from the slot

    Hello! I need to get the QAction text/title from the action's callback/slot. I.e. when an action is triggered and the foo() slot function is called I need to get an action's text/title inside of the foo(). How I can do that?

  2. #2
    Join Date
    Mar 2008
    Posts
    141
    Thanks
    10
    Thanked 9 Times in 9 Posts

    Default Re: getting QAction text from the slot

    What about QAction->text() ?

  3. #3
    Join Date
    Sep 2006
    Posts
    46
    Thanks
    2
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: getting QAction text from the slot

    In your slot use

    Qt Code:
    1. QAction *Act = qobject_cast<QAction *>(sender());
    To copy to clipboard, switch view to plain text mode 

  4. The following 2 users say thank you to merlvingian for this useful post:

    ntp (24th February 2009), roxton (18th April 2008)

  5. #4
    Join Date
    Apr 2008
    Posts
    104
    Thanks
    8
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: getting QAction text from the slot

    Thank's a lot! "QAction *Act = qobject_cast<QAction *>(sender());" is just what I need!

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49
  2. QTableWidgetItem Text Editing
    By ToddAtWSU in forum Qt Programming
    Replies: 2
    Last Post: 17th March 2009, 02:23
  3. Problem pasting text into a QTextEdit
    By Spockmeat in forum Qt Programming
    Replies: 8
    Last Post: 14th March 2009, 14:36
  4. QTextEdit slow to insert text
    By thomaspu in forum Qt Programming
    Replies: 4
    Last Post: 10th January 2008, 12:05
  5. Editable text in QGraphicsView
    By wysota in forum Qt Programming
    Replies: 8
    Last Post: 24th February 2007, 15:30

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.