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 determine in MainWindow's mouseReleaseEvent() whether mouse is over a specific widget
Qt 6.11 is out! See what's new in the release blog

How to determine in MainWindow's mouseReleaseEvent() whether mouse is over a specific widget

Scheduled Pinned Locked Moved Unsolved General and Desktop
21 Posts 2 Posters 6.9k Views 1 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.
  • NiagarerN Niagarer

    @mrjj
    Ok, so using a delegate class with the ListView would be the best way, if I understood correctly.
    I unfortunately can't use jsut a thumbnail pixmap, the user should be able to interact with the widget and the widget should be able to display many things (but every item I add to the ListView would be from the same widget class, otherwise I could not use a ListView, I have read).
    Would I still have these handeling features in a ListWidget like drag and drop in the ListView? If yes, is it more easy to implement this in a ListWidget or does it not really make a difference?

    mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by
    #9

    @Niagarer
    It will have drag & drop support but its ment for the normal items and if u have full blown
    widgets instead, you will need to add support for those.
    The delegate must be able to draw (in code) the looks of the real widget so
    if its complex widgets, it will be tons of work.
    But yes it could work.

    How many of these custom widgets are we talking about?

    NiagarerN 1 Reply Last reply
    0
    • mrjjM mrjj

      @Niagarer
      It will have drag & drop support but its ment for the normal items and if u have full blown
      widgets instead, you will need to add support for those.
      The delegate must be able to draw (in code) the looks of the real widget so
      if its complex widgets, it will be tons of work.
      But yes it could work.

      How many of these custom widgets are we talking about?

      NiagarerN Offline
      NiagarerN Offline
      Niagarer
      wrote on last edited by Niagarer
      #10

      @mrjj
      If I'm unlucky, one day it could go to a thousand.
      So I should not use a ListWidget if I understood correctly, but a ListView will be tons of work...
      :/
      I thought, this would not be such a big problem >.<

      mrjjM 1 Reply Last reply
      0
      • NiagarerN Niagarer

        @mrjj
        If I'm unlucky, one day it could go to a thousand.
        So I should not use a ListWidget if I understood correctly, but a ListView will be tons of work...
        :/
        I thought, this would not be such a big problem >.<

        mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #11

        @Niagarer
        Then both setItemWidget and ScrolLArea will potentially be very slow.
        Depending on the hardware it must run on. The memory alone will be high.

        Are all those different ?

        NiagarerN 1 Reply Last reply
        0
        • mrjjM mrjj

          @Niagarer
          Then both setItemWidget and ScrolLArea will potentially be very slow.
          Depending on the hardware it must run on. The memory alone will be high.

          Are all those different ?

          NiagarerN Offline
          NiagarerN Offline
          Niagarer
          wrote on last edited by Niagarer
          #12

          @mrjj
          Well the widget objects will come from the same class. What I mean is that I display only widget objects from f.e. MyWidget-class but with different text shown, and a different icon and some more different icons I will add to the widgets in the MyWidget-class, but the class is just one. (Actually I wanted to make two different ones for a QTreeWidget, but I guess I sould avoid that, it seems to be hard...)
          Yes, actually I wanted to make it runnable on very slow hardware

          mrjjM 1 Reply Last reply
          0
          • NiagarerN Niagarer

            @mrjj
            Well the widget objects will come from the same class. What I mean is that I display only widget objects from f.e. MyWidget-class but with different text shown, and a different icon and some more different icons I will add to the widgets in the MyWidget-class, but the class is just one. (Actually I wanted to make two different ones for a QTreeWidget, but I guess I sould avoid that, it seems to be hard...)
            Yes, actually I wanted to make it runnable on very slow hardware

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #13

            @Niagarer
            Then no doubt you should use a delegate.
            Also since its only the data that changes, then it wont be so much work
            as if many different widgets.

            1 Reply Last reply
            0
            • mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #14

              Do you have a picture of what you want ?

              NiagarerN 2 Replies Last reply
              0
              • mrjjM mrjj

                Do you have a picture of what you want ?

                NiagarerN Offline
                NiagarerN Offline
                Niagarer
                wrote on last edited by Niagarer
                #15

                @mrjj
                Well actually yes, give me a minute, the engine has to start...

                1 Reply Last reply
                1
                • mrjjM mrjj

                  Do you have a picture of what you want ?

                  NiagarerN Offline
                  NiagarerN Offline
                  Niagarer
                  wrote on last edited by Niagarer
                  #16

                  @mrjj
                  In the end I would really like to have something like this:
                  0_1509394698450_Qt 19.png
                  With the List I want only to represent the content inside the green rect.
                  I think I will not need the tree structure, only these widgets with f.e. this f, because once this list gets very big, only the search function will be used anymore (but if it is completele a joke to implement it with a treeList after I get it work with the ListView, I would appreciate it). But I would like to add some more little icons like that at the right side of the widget.

                  mrjjM 1 Reply Last reply
                  0
                  • NiagarerN Niagarer

                    @mrjj
                    In the end I would really like to have something like this:
                    0_1509394698450_Qt 19.png
                    With the List I want only to represent the content inside the green rect.
                    I think I will not need the tree structure, only these widgets with f.e. this f, because once this list gets very big, only the search function will be used anymore (but if it is completele a joke to implement it with a treeList after I get it work with the ListView, I would appreciate it). But I would like to add some more little icons like that at the right side of the widget.

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #17

                    @Niagarer
                    So its like a text line with some icons ?

                    What is the "Get BlackBoard thing ?"

                    NiagarerN 1 Reply Last reply
                    0
                    • mrjjM mrjj

                      @Niagarer
                      So its like a text line with some icons ?

                      What is the "Get BlackBoard thing ?"

                      NiagarerN Offline
                      NiagarerN Offline
                      Niagarer
                      wrote on last edited by Niagarer
                      #18

                      @mrjj
                      Thats a tooltip, the mouse was over the Get Blackboard thing and on the left of the widget there is also shown a little pushButton (the little star) to mark it as favourite (because the mouse was over this component).

                      mrjjM 1 Reply Last reply
                      0
                      • NiagarerN Niagarer

                        @mrjj
                        Thats a tooltip, the mouse was over the Get Blackboard thing and on the left of the widget there is also shown a little pushButton (the little star) to mark it as favourite (because the mouse was over this component).

                        mrjjM Offline
                        mrjjM Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on last edited by
                        #19

                        @Niagarer

                        Ok. i think a delegate will work super since its relatively simple structure.
                        We often refer to
                        http://doc.qt.io/qt-5/qtwidgets-itemviews-stardelegate-example.html
                        for delegate sample

                        NiagarerN 1 Reply Last reply
                        1
                        • mrjjM mrjj

                          @Niagarer

                          Ok. i think a delegate will work super since its relatively simple structure.
                          We often refer to
                          http://doc.qt.io/qt-5/qtwidgets-itemviews-stardelegate-example.html
                          for delegate sample

                          NiagarerN Offline
                          NiagarerN Offline
                          Niagarer
                          wrote on last edited by Niagarer
                          #20

                          @mrjj
                          In the example, a QTableWidget is used. And so it has no model (no QAbstractItemModel, the struct is actually the model). Would all this also work with QListViews or QTableViews?

                          mrjjM 1 Reply Last reply
                          0
                          • NiagarerN Niagarer

                            @mrjj
                            In the example, a QTableWidget is used. And so it has no model (no QAbstractItemModel, the struct is actually the model). Would all this also work with QListViews or QTableViews?

                            mrjjM Offline
                            mrjjM Offline
                            mrjj
                            Lifetime Qt Champion
                            wrote on last edited by
                            #21

                            @Niagarer
                            Yes the delegate is the same regardless of the view/widget used.
                            http://doc.qt.io/qt-5/model-view-programming.html

                            The delegate can be seen as way to custom paint.

                            1 Reply Last reply
                            1

                            • Login

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