Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to generate signal when item is entered by code.
Forum Updated to NodeBB v4.3 + New Features

How to generate signal when item is entered by code.

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 5 Posters 1.1k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on 3 May 2021, 17:42 last edited by
    #1

    I can go down the options or ASK. here .

    I need to have signal generated when "item is entered" into QListWidget list by another signal.
    No manual selection.

    QtDesigner suggests "go to slot " options and I have tried

    currentItemChanged
    currentTextChanged
    itemChanged
    itemEntered

    122c09d1-c1be-4111-baf7-0cf50845c47a-image.png

    J 1 Reply Last reply 4 May 2021, 09:28
    0
    • G Offline
      G Offline
      gde23
      wrote on 3 May 2021, 20:35 last edited by
      #2

      What do you mean by "item is entered by code"?

      A 1 Reply Last reply 3 May 2021, 21:10
      1
      • G gde23
        3 May 2021, 20:35

        What do you mean by "item is entered by code"?

        A Offline
        A Offline
        Anonymous_Banned275
        wrote on 3 May 2021, 21:10 last edited by
        #3

        @gde23 Entry to list widget is generated by running code , not manually.

        P 1 Reply Last reply 3 May 2021, 21:23
        0
        • A Anonymous_Banned275
          3 May 2021, 21:10

          @gde23 Entry to list widget is generated by running code , not manually.

          P Offline
          P Offline
          Pl45m4
          wrote on 3 May 2021, 21:23 last edited by
          #4

          @AnneRanch

          You mean "added"?
          "Enter" in this case means, your mouse enters the item.


          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

          ~E. W. Dijkstra

          A 1 Reply Last reply 3 May 2021, 23:27
          1
          • P Pl45m4
            3 May 2021, 21:23

            @AnneRanch

            You mean "added"?
            "Enter" in this case means, your mouse enters the item.

            A Offline
            A Offline
            Anonymous_Banned275
            wrote on 3 May 2021, 23:27 last edited by
            #5

            @Pl45m4 OK. that eliminates signals with "enter" in it.
            Lets define "current" next.

            P 1 Reply Last reply 4 May 2021, 09:22
            0
            • A Anonymous_Banned275
              3 May 2021, 23:27

              @Pl45m4 OK. that eliminates signals with "enter" in it.
              Lets define "current" next.

              P Offline
              P Offline
              Pl45m4
              wrote on 4 May 2021, 09:22 last edited by
              #6

              @AnneRanch said in How to generate signal when item is entered by code.:

              Lets define "current" next

              "current" means the current / active (focused) item in your QListWidget.
              For example, currentItemChanged passes the last and the new/current focused item to your slot.


              If debugging is the process of removing software bugs, then programming must be the process of putting them in.

              ~E. W. Dijkstra

              A 1 Reply Last reply 4 May 2021, 12:21
              2
              • A Anonymous_Banned275
                3 May 2021, 17:42

                I can go down the options or ASK. here .

                I need to have signal generated when "item is entered" into QListWidget list by another signal.
                No manual selection.

                QtDesigner suggests "go to slot " options and I have tried

                currentItemChanged
                currentTextChanged
                itemChanged
                itemEntered

                122c09d1-c1be-4111-baf7-0cf50845c47a-image.png

                J Offline
                J Offline
                J.Hilk
                Moderators
                wrote on 4 May 2021, 09:28 last edited by
                #7

                @AnneRanch what you're looking for is probably signals. coming from the underlying model that QListWidget implements

                https://doc.qt.io/qt-5/qabstractitemmodel.html#signals

                I don't think you can get access to the model from a QListWidget, you will have to use a QListView and manage your own Model, that you can listen to

                Or define your own signal, that you emit, when you add staff to the QListWidget


                Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                Q: What's that?
                A: It's blue light.
                Q: What does it do?
                A: It turns blue.

                1 Reply Last reply
                2
                • P Pl45m4
                  4 May 2021, 09:22

                  @AnneRanch said in How to generate signal when item is entered by code.:

                  Lets define "current" next

                  "current" means the current / active (focused) item in your QListWidget.
                  For example, currentItemChanged passes the last and the new/current focused item to your slot.

                  A Offline
                  A Offline
                  Anonymous_Banned275
                  wrote on 4 May 2021, 12:21 last edited by
                  #8

                  @Pl45m4 said in How to generate signal when item is entered by code.:

                  @AnneRanch said in How to generate signal when item is entered by code.:

                  Lets define "current" next

                  "current" means the current / active (focused) item in your QListWidget.
                  For example, currentItemChanged passes the last and the new/current focused item to your slot.

                  That is not that clear.

                  "passes" implies the item is again selected - by mouse or keyboard.
                  "focused" is same - the item is selected - by mouse or keyboard.

                  I need to process the item BEFORE it is added to the list.

                  @J-Hilk said in How to generate signal when item is entered by code.:

                  @AnneRanch what you're looking for is probably signals. coming from the underlying model that QListWidget implements

                  https://doc.qt.io/qt-5/qabstractitemmodel.html#signals

                  I don't think you can get access to the model from a QListWidget, you will have to use a QListView and manage your own Model, that you can listen to

                  and you are correct

                  Or define your own signal, that you emit, when you add staff to the QListWidget

                  See my next to last post - process the item signal - BEFORE - it get added to the list.
                  Sort to messes up the logical flow of events, but definitely simplify the process.

                  P 1 Reply Last reply 4 May 2021, 14:36
                  0
                  • A Anonymous_Banned275
                    4 May 2021, 12:21

                    @Pl45m4 said in How to generate signal when item is entered by code.:

                    @AnneRanch said in How to generate signal when item is entered by code.:

                    Lets define "current" next

                    "current" means the current / active (focused) item in your QListWidget.
                    For example, currentItemChanged passes the last and the new/current focused item to your slot.

                    That is not that clear.

                    "passes" implies the item is again selected - by mouse or keyboard.
                    "focused" is same - the item is selected - by mouse or keyboard.

                    I need to process the item BEFORE it is added to the list.

                    @J-Hilk said in How to generate signal when item is entered by code.:

                    @AnneRanch what you're looking for is probably signals. coming from the underlying model that QListWidget implements

                    https://doc.qt.io/qt-5/qabstractitemmodel.html#signals

                    I don't think you can get access to the model from a QListWidget, you will have to use a QListView and manage your own Model, that you can listen to

                    and you are correct

                    Or define your own signal, that you emit, when you add staff to the QListWidget

                    See my next to last post - process the item signal - BEFORE - it get added to the list.
                    Sort to messes up the logical flow of events, but definitely simplify the process.

                    P Offline
                    P Offline
                    Pl45m4
                    wrote on 4 May 2021, 14:36 last edited by
                    #9

                    @AnneRanch said in How to generate signal when item is entered by code.:

                    See my next to last post - process the item signal - BEFORE - it get added to the list.

                    If you do it on your own, you can decide when you emit it.
                    Write your own addItem function, emit your custom signal in there and then actually add your item to your QListWidget.


                    If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                    ~E. W. Dijkstra

                    1 Reply Last reply
                    2
                    • mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on 4 May 2021, 15:06 last edited by
                      #10

                      Hi
                      Its also possible to do

                       auto m =  ui->listWidget->model() ;
                       connect(m, &QAbstractItemModel::rowsInserted, this, [m](const QModelIndex &parent, int first, int last){
                             m->setData(m->index(first,0/*col*/), "replaced!" );
                           } );
                      
                           ui->listWidget->addItem("JUBII");
                      
                      

                      alt text

                      1 Reply Last reply
                      2

                      1/10

                      3 May 2021, 17:42

                      • Login

                      • Login or register to search.
                      1 out of 10
                      • First post
                        1/10
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved