[SOLVED] Warning "C4273: Inconsistent dll linkage" when reimplementing QHeaderView::mousePressEvent(QMouseEvent *event)
-
"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.
-
Hi,
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.My header:
@class VDatagridView : public QWidget
{
Q_OBJECTpublic:
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?
-
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.
-
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()?
-
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. -
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. ;)