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



  • When I reimplement the QHeaderView::mousePressEvent(QMouseEvent *event) in my class, I get the warning C4273.
    The program seems to run well though.
    How could I fix this and why is it caused?


  • Moderators

    "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.


  • Lifetime Qt Champion

    Hi,

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

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


  • Moderators

    [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 ^^



  • 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?


  • Moderators

    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.



  • 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)@



  • 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()?


  • Lifetime Qt Champion

    How does your custom QHeaderView look like ?



  • 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.



  • 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.


  • Moderators

    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. ;)



  • Stupid me..

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

    Thanks a lot!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.