【问题标题】:Undefined reference to vtable when inheriting QFrame继承 QFrame 时对 vtable 的未定义引用
【发布时间】:2015-04-08 02:11:24
【问题描述】:

我在 Windows 8.1 Pro x64 上使用 Qt 5.4 x86。在this example 之后,我正在尝试实现ElidedLabel 类。不知道我做错了什么,但示例中的代码本身正在生成

error: undefined reference to `vtable for ElidedLabel'

出了什么问题以及如何解决?我检查了Qt 5.4 documentation of QFrame,没有需要定义的纯虚函数。

【问题讨论】:

  • 也许 moc 没有预处理你的代码,所以尝试从菜单中的 Build > Run qmake 命令。
  • @Chernobyl:是的,它有效!您能否将其发布为答案,以便我接受?
  • 是的,当然,谢谢。

标签: c++ qt


【解决方案1】:

moc (Meta Object Compiler) 没有预处理你的代码,所以你得到这个不是很清楚的错误。

解决方案:尝试菜单中的Build > Run qmake 命令。此命令将运行 moc 并为您的类生成正确的代码。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-03-13
    • 2014-09-24
    • 1970-01-01
    • 2016-10-19
    • 1970-01-01
    • 1970-01-01
    • 2012-08-14
    相关资源
    最近更新 更多