[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?
please post the definition and declaration of this method in your class or the whole class if it's not so big.
Could you show the header file where you declare the mousePressEvent ?
Edit: raven-worx almost the same time again :D
[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.
@class VDatagridView : public QWidget
explicit VDatagridView(QWidget *parent = 0);
void mousePressEvent(QMouseEvent *event);
bool eventFilter(QObject *obj, QEvent *event);
@void QHeaderView::mousePressEvent(QMouseEvent *event)
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?
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)@
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()?
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
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.
actually you should never have an implementation of
anywhere in your code.
Instead it should only look like this:
//and call base class implementation if needed INSIDE the reimplementation
Since the methods are virtual the compiler calls the hierarchically most derived method implementation automagically. ;)
Indeed, this is the way that I have done it..
I just did a really bad description above..
Thanks a lot!
This post is deleted!