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. [SOLVED] Warning "C4273: Inconsistent dll linkage" when reimplementing QHeaderView::mousePressEvent(QMouseEvent *event)
Forum Update on Monday, May 27th 2025

[SOLVED] Warning "C4273: Inconsistent dll linkage" when reimplementing QHeaderView::mousePressEvent(QMouseEvent *event)

Scheduled Pinned Locked Moved General and Desktop
14 Posts 4 Posters 14.7k Views
  • 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.
  • raven-worxR Offline
    raven-worxR Offline
    raven-worx
    Moderators
    wrote on last edited by
    #2

    "error C4273":http://msdn.microsoft.com/en-us/library/35bhkfb6.aspx

    please post the definition and declaration of this method in your class or the whole class if it's not so big.

    --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
    If you have a question please use the forum so others can benefit from the solution in the future

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #3

      Hi,

      Could you show the header file where you declare the mousePressEvent ?

      Edit: raven-worx almost the same time again :D

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by
        #4

        [quote author="SGaist" date="1379499858"]
        Edit: raven-worx almost the same time again :D[/quote]
        yes... one of the rare cases were i was quicker by a few seconds ^^

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        0
        • G Offline
          G Offline
          geracmos
          wrote on last edited by
          #5

          I think that I found out what it was..
          I had two mousePressEvent(QMouseEvent *event) functions in my class.

          My header:
          @class VDatagridView : public QWidget
          {
          Q_OBJECT

          public:
          explicit VDatagridView(QWidget *parent = 0);
          ~VDatagridView();

          protected:
          void mousePressEvent(QMouseEvent *event);
          bool eventFilter(QObject *obj, QEvent *event);
          };@

          My code:
          @void QHeaderView::mousePressEvent(QMouseEvent *event)
          {
          //blah blah
          }

          void VDatagridView::mousePressEvent(QMouseEvent *event)
          {
          //other blah blah
          }@

          Although I tried to erase the second one, the problem kept occuring, until I cleaned the whole project and then everything was ok.

          But shouldn't I be able to have both of them in my class with no problems?

          1 Reply Last reply
          0
          • raven-worxR Offline
            raven-worxR Offline
            raven-worx
            Moderators
            wrote on last edited by
            #6

            why do you want QHeaderView::mousePressEvent() declared in your code?
            I mean why with the class specifier of QHeaderView? This just isn't correct.

            I wonder why this is only a warning rather than a error.

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            0
            • G Offline
              G Offline
              geracmos
              wrote on last edited by
              #7

              No ,I have to correct myself..

              The warning shows up even with the
              @VDatagridView::mousePressEvent(QMouseEvent *event) @
              renamed to something new like @VDatagridView::customMousePressEvent(QMouseEvent *event)@

              1 Reply Last reply
              0
              • G Offline
                G Offline
                geracmos
                wrote on last edited by
                #8

                raven-worx:

                In my QTableView I use a custom header which inherits QHeaderView.

                I tried to reimplement the QHeaderView::mousePressEvent()
                because that was the only way that I know to get the QEvent::MouseButtonPress
                and use it in my class.

                That's because my own implementation of mousePressEvent() could handle mouse clicks that were outside of the QTableView only.

                Should I consider the solution of eventFilter()?

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #9

                  How does your custom QHeaderView look like ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    geracmos
                    wrote on last edited by
                    #10

                    I use the "HierarchicalHeaderView":http://qt-apps.org/content/show.php?content=103154&forumpage=2
                    because I need a multiple-level header for my QTableView.

                    1 Reply Last reply
                    0
                    • G Offline
                      G Offline
                      geracmos
                      wrote on last edited by
                      #11

                      Well I think that I have found the solution:

                      I erased the reimplementation of
                      @QHeaderView::mousePressEvent(QMouseEvent *event)@

                      in VDatagridView class and I did that into the HierarchicalHeaderView class which is responsible only for drawing the Headers.
                      So when I click on the Header a mousePressEvent occurs in the HierarchicalHeaderView and the QHeaderView::mousePressEvent() is called.
                      When I click somewhere else on my ui, then the VDatagridView::mousePressEvent() is called.

                      1 Reply Last reply
                      0
                      • raven-worxR Offline
                        raven-worxR Offline
                        raven-worx
                        Moderators
                        wrote on last edited by
                        #12

                        actually you should never have an implementation of
                        @
                        QHeaderView::mousePressEvent(QMouseEvent *event)
                        @
                        anywhere in your code.
                        Instead it should only look like this:
                        @
                        MyClass::mousePressEvent(QMouseEvent *event)
                        {
                        //and call base class implementation if needed INSIDE the reimplementation
                        QHeaderView::mousePressEvent(event)
                        }
                        @
                        Since the methods are virtual the compiler calls the hierarchically most derived method implementation automagically. ;)

                        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                        If you have a question please use the forum so others can benefit from the solution in the future

                        1 Reply Last reply
                        0
                        • G Offline
                          G Offline
                          geracmos
                          wrote on last edited by
                          #13

                          Stupid me..

                          Indeed, this is the way that I have done it..
                          I just did a really bad description above..

                          Thanks a lot!

                          1 Reply Last reply
                          0
                          • F Offline
                            F Offline
                            Ferrel987
                            Banned
                            wrote on last edited by
                            #14
                            This post is deleted!
                            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