找不到'QAbstractItemViewPrivate'值的虚拟表的链接器符号
can't find linker symbol for virtual table for 'QAbstractItemViewPrivate' value
我在为用户界面开发代码时面临问题。我正在使用Yocto部署的Linux发行版上使用QT 4.8。这里是我的代码的真正简单片段:
// MyWidget.h
class MyWidget : public QWidget
{
Q_OBJECT
public:
MyWidget( QWidget* parent );
~MyWidget();
signals:
void request_GoToNext( QString ); //!< Go to next panel
private slots:
void onNext( QModelIndex index );
private:
QTableView *tableView;
QStandardItemModel *dataModel;
}
// MyWidget.cpp
MyWidget::MyWidget( QWidget *parent ) : QWidget(parent)
{
this->tableView = new QTableView(this);
this->dataModel = new QStandardItemModel();
// "Fill-in" data model with the list of files in a specific directory
...
connect( this->tableView, SIGNAL(clicked(QModelIndex)), this, SLOT(onNext(QModelIndex)), Qt::UniqueConnection );
}
MyWidget::~MyWidget()
{
disconnect( this->tableView, SIGNAL(clicked(QModelIndex)), this, SLOT(onNext(QModelIndex)) );
this->dataModel->clear();
delete this->tableView;
delete this->dataModel;
}
void MyWidget::onNext( QModelIndex index )
{
emit this->request_GoToNext( this->dataModel->item(index.row(), index.column())->text() );
}
问题在发出信号" request_gotonext"时具有起源,这会使应用程序崩溃或由于分段故障而导致的调试停止。我可以看到的是,在qtCreator中,该应用程序似乎失败的点是在文件qabstractitemview.cpp中,在此功能中更具体:
QStyleOptionViewItemV4 QAbstractItemViewPrivate::viewOptionsV4() const
{
Q_Q(const QAbstractItemView);
QStyleOptionViewItemV4 option = q->viewOptions();
if (wrapItemText)
option.features = QStyleOptionViewItemV2::WrapText;
option.locale = q->locale();
option.locale.setNumberOptions(QLocale::OmitGroupSeparator);
option.widget = q;
return option;
}
对我来说,这听起来真的很奇怪。发出信号后,该应用程序应删除当前面板并构建另一个面板:设置一些" Qdebug"调用,这似乎发生了,删除了当前面板(及其子女)并创建一个新的面板,但是该应用程序在显示新面板之前失败了。删除与mywidget相关的所有内容后,该程序似乎"退出"了插槽" onnext"。
另外,在qtCreator的TEH应用程序输出中,我可以阅读此消息
找不到" qabstractitemviewprivate"值的虚拟表的链接符号
nb-观察如果我以这种方式重写插槽内的代码
void MyWidget::onNext( QModelIndex index )
{
QObject::startTimer(1);
emit this->request_GoToNext( this->dataModel->item(index.row(), index.column())->text() );
}
void MyWidget::timerEvent( QTimerEvent *event )
{
QObject::killeTimer( event->timerId() );
emit this->request_GoToNext( this->dataModel->item(index.row(), index.column())->text() );
}
一切正常!这就是为什么它似乎与"退出"插槽呼叫我有关的原因。
非常感谢您的帮助
在其他一些测试之后,我认为我发现哪个是问题以及如何解决。
在这里,我的代码的简化片段,其中有一个类父母使用的类按钮。单击按钮时,它可能会导致面板更改,或提出消息或执行其他操作(与问题无关的详细措施)。
我发现的是slot class button 的关注:输入第一个如果,该程序发出信号 request_gotoprev <</em>/em>,这会导致类面板删除当前面板(及其子女,甚至包含了按钮!)并提高了一个新的。但是,在发出信号并执行所有需要的操作后,该程序"恢复"到发出信号并继续执行的点:当它到达第二个时,它是因为>这个不再是一致的。
这就是我的测试后的样子。如果解决问题,请在第一个中放置信号发射之后,将A 返回。
// HEADER: Button.h
class Button : public QPushButton
{
Q_OBJECT
public:
Button( QWidget *parent = 0 );
~Button();
signals:
void request_GoToPrev(); //!< Go to previous panel
void request_GoToNext( QString ); //!< Go to next panel
void signal_Error( int ); //!< Error code
private slots:
void onClicked();
private:
typ_Button_tags *widgetTags; //!< Pointer to the tags structure that defines the ref Button widget
typ_Shared *privateCtx; //!< Reference to runtime application structure
};
// C: Button.cpp
Button::Button( QWidget *parent )
:
QPushButton(parent)
{
// Do some settings, like: font, stylesheet, focus, size..
}
Button::~Button()
{
}
void Button::onClicked()
{
// Callback to be called when button clicked
if( !this->widgetTags->callbackClick.isEmpty() )
{
emit this->request_GoToPrev();
/* !!! ATTENTION !!!
*
* Here the instruction return HAS to be written, otherwise the application crashes.
* In fact, when running, the signal 'request_GoToPrev' is sent, but the flow of the
* process should exit the call of this slot.
* Doing that, 'this' is no more consistent after having emitted the signal, so the
* application face a segmentation fault.
*/
return;
}
// Message box
if( !this->widgetTags->msgText.isEmpty() )
{
// Do some other actions on 'this'...
}
}
// HEADER: Panel.h
class Panel : public QMainWindow
{
Q_OBJECT
public:
Panel( QWidget *parent = 0 );
private slots:
void on_GoToNext(int index);
void on_GoToPrevious();
void on_Error(int errId);
private:
Button *Btn;
};
// C: Panel.h
Panel::Panel( QWidget *parent )
:
QMainWindow(parent)
{
// Do some settings: font, stylesheet, focus, size...
this->Btn = new Button( this );
connect( this->Btn, SIGNAL(request_GoToPrev()), this, SLOT(on_GoToPrevious()), Qt::UniqueConnection );
// Do some actions to layout the button inside the panel
}
void Panel::on_GoToPrevious()
{
// Do some check...
delete this->Btn;
// Do some actions...
}
- 使用gcc从静态链接的文件中查找可选符号
- 链接器找不到在虚拟类 c++ 中访问的静态字段的符号
- Windows 链接器是否使用 LoadLibrary 解析 DLL 中未定义的符号?
- 如果我想链接静态库并删除未使用的符号.txt我应该如何处理 Cmakelist
- clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用) - 体系结构的未定义符号 x86_64:
- emscripten 链接全局命名符号乘法定义
- 体系结构x86_64的未定义符号:链接器错误
- 共享对象、符号、C/C++ 库链接和加载
- 如何防止 CMake 在构建时(而不是在安装时)为共享库创建符号链接?
- 如何将空文件夹和符号链接添加到存档 - libarchive
- 协议缓冲区的静态链接会导致与现有符号冲突
- 链接器错误:切换到unicode生成给出:未解析的外部符号WinMain
- SWIG链接器:未定义符号:_ZN2cv8fastFreeEPv(cv::fastFree(void*))
- 使用共享库编译可执行文件时仅链接所需的符号
- 为什么链接器报告全局函数的乘法定义符号,而不是类静态方法
- 未定义的引用,即使库正在链接并且它包含正确的符号
- C++ 链接器错误 LNK 2019 函数中引用的未解析的外部符号
- boost::存在符号链接不取消引用
- 检测无意的弱链接符号
- c++ Linux静态变量的双重析构.链接符号重叠