Results 1 to 6 of 6

Thread: 2 QListWidget - move Entry between Widgets

  1. #1
    Join Date
    May 2009
    Location
    Austria
    Posts
    21
    Qt products
    Qt4
    Platforms
    Windows

    Question 2 QListWidget - move Entry between Widgets

    Hello,

    I have a little problem with my application...

    I have 2 QListWidgets which I make dynamic in a vertical layout (it also can be 3 QListWidgets) and I want to move an Entry from the 1 Widget in the 2 Widget and so on...

    The move from one Widget to the other Widget is not the problem...
    I want to check if the Entry was moved is already in this Widget.
    I want to check if the Entry exists in the other Widget.

    Is there any SIGNAL or Event where I can handle this?

    I hope someone can help me...

    greetings

  2. #2
    Join Date
    Aug 2006
    Posts
    221
    Thanks
    3
    Thanked 29 Times in 19 Posts

    Default Re: 2 QListWidget - move Entry between Widgets

    Do you know the assistant? Gives you a fantastic overview, what signals/events a widget has and what not.
    If you'd use it you'd quickly find that the answer is no.

    And your question is a bit strange. You mean before the entry was moved? After the answer would always
    be yes. And the test if an entry already exists:

    QList<QListWidgetItem *> QListWidget::findItems ( const QString & text, Qt::MatchFlags flags ) const
    Finds items with the text that matches the string text using the given flags.

    Also found in the assistant.

  3. #3
    Join Date
    May 2009
    Location
    Austria
    Posts
    21
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: 2 QListWidget - move Entry between Widgets

    Thanks for your answer...

    I mean after the entry was moved...
    I need a Signal or something to connect to a function that I can check if an entry exists...

    like
    connect(listwidget, SIGNAL(currentItemChanged()....SLOT(WidgetChanged( )....

  4. #4
    Join Date
    Aug 2006
    Posts
    221
    Thanks
    3
    Thanked 29 Times in 19 Posts

    Default Re: 2 QListWidget - move Entry between Widgets

    But after an entry was moved it always exists in the list widget. Isn't that the point of moving?

    There is no signal or event which tells you that a new item has been added.
    Why do you need this signal? Don't you know when you add something in you
    QListWidget? In that case you could emit such a signal yourself.
    And you don't need a signal to check whether an entry exists. You call
    QList<QListWidgetItem *> QListWidget::findItems ( const QString & text, Qt::MatchFlags flags ) const
    If the list is empty, the item does not exists.
    Somehow I don't understand your requirements.

  5. #5
    Join Date
    May 2009
    Location
    Austria
    Posts
    21
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: 2 QListWidget - move Entry between Widgets

    Now I`ve solved the problem...
    I have seen in a book an example and I do it like this and now it works like I will...

    When I move now something in the QListWidget I got in the function "dropEvent"...
    That`s what I want...

    But now I`ve a little problem...
    I have to knew the sender. When I move, for instance from a red widget in a yellow widget, I have to knew from where the entry come...

  6. #6
    Join Date
    Aug 2006
    Posts
    221
    Thanks
    3
    Thanked 29 Times in 19 Posts

    Default Re: 2 QListWidget - move Entry between Widgets

    Quote Originally Posted by reinki0013 View Post
    Now I`ve solved the problem...
    I have seen in a book an example and I do it like this and now it works like I will...

    When I move now something in the QListWidget I got in the function "dropEvent"...
    That`s what I want...

    But now I`ve a little problem...
    I have to knew the sender. When I move, for instance from a red widget in a yellow widget, I have to knew from where the entry come...
    You did not mention drag and drop.

    But look here:
    QWidget * QDropEvent::source () const

Similar Threads

  1. Move items up and down in QListWidget
    By araglin in forum Newbie
    Replies: 7
    Last Post: 31st August 2016, 11:05
  2. Problem in Move Move Event Handler.
    By redgoof in forum Qt Programming
    Replies: 0
    Last Post: 7th April 2010, 11:45
  3. Hiding an entry from a QMenuBar in Qt4?
    By joelthelion in forum Qt Programming
    Replies: 1
    Last Post: 24th March 2010, 14:45
  4. getting entry from QListView
    By herbstritter in forum Newbie
    Replies: 3
    Last Post: 20th March 2010, 17:02
  5. Move Rectangle on mouse Move
    By vermarajeev in forum Qt Programming
    Replies: 24
    Last Post: 14th May 2007, 05:34

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.