Baffling gcc complaint about usage of Qt4 setValidator
We're stumped as to why gcc complains about this line in our app:
doubleFrom->setValidator(new QDoubleValidator(doubleFrom));
with these complaints:
error: expected type-specifie开发者_开发问答r before 'QDoubleValidator'
error: expected `)' before 'QDoubleValidator'
error: no matching function for call to 'QLineEdit::setValidator(int*)'
candidates are: void QLineEdit::setValidator(const QValidator*)
(I've chopped out long-winded paths to files, line numbers.)
Yes, setValidator wants to be fed a const QValidator*, and that's what we're doing in that one line of source. Why does gcc want to see a ')' prematurely, and think we're feeding setValidator an int*?
Of course, "this compiled fine yesterday, and we haven't changed anything. Really!"
This is really basic and obvious, I know, but did you #include <QDoubleValidator>
?
"Expected type-specifier before <identifier that should name a type>" almost always means that the type definition isn't visible.
精彩评论