[SOLVED] Warning "C4273: Inconsistent dll linkage" when reimplementing QHeaderView::mousePressEvent(QMouseEvent *event)
-
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 ^^ -
wrote on 18 Sept 2013, 11:38 last edited by
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.
-
wrote on 18 Sept 2013, 11:52 last edited by
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)@ -
wrote on 18 Sept 2013, 12:00 last edited by
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 ?
-
wrote on 19 Sept 2013, 07:10 last edited by
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. -
wrote on 19 Sept 2013, 10:10 last edited by
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. ;) -
wrote on 19 Sept 2013, 10:21 last edited by
Stupid me..
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!