Results 1 to 4 of 4

Thread: directly passing text() trough slot from QListWidgetItem

  1. #1
    Join Date
    Jul 2012
    Posts
    4

    Default directly passing text() trough slot from QListWidgetItem

    Hi

    I have something like:
    Qt Code:
    1. connect( list, SIGNAL( itemDoubleClicked( QListWidgetItem* ) ), this, SLOT( slotFromListWidget( QListWidgetItem* ) ) );
    To copy to clipboard, switch view to plain text mode 
    and then in slotFromListWidget function we do some things with item->text(). Is there any way to directly pass the text() return value?
    I mean something like
    Qt Code:
    1. connect( list, SIGNAL( itemDoubleClicked( QListWidgetItem* ) ), this, SLOT( slotFromListWidget( (QListWidgetItem*).text() ) ) );
    To copy to clipboard, switch view to plain text mode 
    while the slot will be
    Qt Code:
    1. slotFromListWidget(QString str)
    To copy to clipboard, switch view to plain text mode 
    but such things don't work.

    Thanks in advance.

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: directly passing text() trough slot from QListWidgetItem

    You can either subclass the list widget and add another signal
    Qt Code:
    1. void
    2. mylistclass::myslotfordoubleclick(QListWidgetItem* item)
    3. {
    4. emit mynewstringsignal(item->text());
    5. }
    To copy to clipboard, switch view to plain text mode 
    or just connect the signal with the widgetitem to your other class, making sure the slot signature is correct. But you cannot do anything like you ask in your op.
    Last edited by amleto; 28th July 2012 at 17:03.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  3. #3
    Join Date
    Jul 2012
    Posts
    4

    Default Re: directly passing text() trough slot from QListWidgetItem

    Quote Originally Posted by amleto View Post
    You can either subclass the list widget and add another signal
    That's what I have already done, just wondering if I can 'condense' it in some way.

    Quote Originally Posted by amleto View Post
    or just connect the signal with the widgetitem to your other class, making sure the slot signature is correct
    Could you show some example? I don't know what you mean.

    Thanks for response.

  4. #4
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: directly passing text() trough slot from QListWidgetItem

    I mean this:

    I have something like:
    Qt Code:
    1. connect( list, SIGNAL( itemDoubleClicked( QListWidgetItem* ) ), this, SLOT( slotFromListWidget( QListWidgetItem* ) ) );
    To copy to clipboard, switch view to plain text mode 
    and then in slotFromListWidget function we do some things with item->text()
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

Similar Threads

  1. Passing argument to slot.
    By TCB13 in forum Newbie
    Replies: 2
    Last Post: 22nd February 2012, 19:52
  2. Problem with passing Pointers to a Slot
    By Basti300 in forum Newbie
    Replies: 2
    Last Post: 26th May 2010, 14:45
  3. Passing an integer to a slot
    By bizmopeen in forum Newbie
    Replies: 6
    Last Post: 30th October 2009, 09:51
  4. disconnect SIGNAL/SLOT directly after emitting data
    By donglebob in forum Qt Programming
    Replies: 1
    Last Post: 4th February 2009, 22:53
  5. passing arguments in SLOT
    By eleanor in forum Qt Programming
    Replies: 3
    Last Post: 3rd July 2008, 21:55

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.