Can't find linker symbol for virtual table



  • I have two dialog widgets. One widget passes a QStringList to the other via a signal/slot. The problem "seems" to lie in the signal/slot, but it might have something to do with the QStringList it is trying to pass. Here is the relevant code;

    dialog1.h
    @#ifndef DIALOG1_H
    #define DIALOG1_H
    #include "dialog1.h"
    #include <QString>
    #include <QStringList>

    class Dialog1;

    #include <QDialog>

    namespace Ui {
    class Dialog1;
    }

    class Dialog1 : public QDialog
    {
    Q_OBJECT

    public:
    explicit Dialog1(QWidget *parent = 0);
    ~Dialog1();

    private:
    Ui::Dialog1 *ui;
    Dialog2 *dialog2;

    signals:
    void sendTable(QString);
    void sendReportOptions(QStringList);
    void sendFilter(QString);

    private slots:
    void on_btnPrintPreview_clicked ();

    };

    #endif // DIALOG1_H
    @

    and the relevant cpp
    @#include "dialog1.h"
    #include "ui_dialog1.h"
    #include <QSqlQuery>
    #include <QMessageBox>
    #include <QDebug>

    Dialog1::Dialog1(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog1)
    {
    ui->setupUi(this);
    ui->cmbRunType->setCurrentIndex(-1);

    dialog2 =new Dialog2;
    

    //Signals and slots
    connect(this,SIGNAL(sendReportOptions(QStringList)),
    Dialog2, SLOT(createReportTable(QStringList)));//data for table view

    }

    Dialog1::~Dialog1()
    {
    delete ui;
    }

    void Dialog1::on_btnPrintPreview_clicked()
    {

    QStringList reportOptions;
    QString runName;
    
    if(ui->cmbLoadRun->currentIndex()>=0 && ui->cmbRunType->currentIndex()>=0)
    {
    
    
    //Get states of checkboxes and store them in a QStringList to pass to the print preview.
        
        if (ui->chkItem1->isChecked())
    

    reportOptions<<"FSChecked";
    else
    reportOptions<<"FSNotChecked";

        if (ui->chkItem2->isChecked())
          reportOptions.append("FTireChecked");
        else
          reportOptions.append("FTireNotchecked");
    
        if (ui->chkItem3->isChecked())
    

    reportOptions.append("RSChecked");
    else
    reportOptions.append("RSNotChecked");

        emit sendTable (mTableName);//Sends table name
        emit sendReportOptions(reportOptions);//if I comment out this line, no error
    
        dialog2->exec&#40;&#41;;
    }
    
    
    
    else
    {
    QMessageBox::warning(this,"No Run Selected", "You did not select either a run or a run type!"&#41;;
    ui->cmbLoadRun->setCurrentIndex(-1);
    ui->cmbRunType->setCurrentIndex(-1);
    }
    

    }
    @

    When run, it crashes and I get an error:
    ASSERT: "idx >= 0 && idx < s" in file ....\include/QtCore/../../src/corelib/tools/qvarlengtharray.h, line 107
    Invalid parameter passed to C runtime function.

    And when I run Debug I get an error as soon as it enters the on_btnPrintPreview_clicked() method.
    can't find linker symbol for virtual table for QListData::Data' value foundQString::shared_empty' instead

    and as soon as it gets to the emit sendReportOptions I get an error:
    ASSERT: "idx >= 0 && idx < s" in file ....\include/QtCore/../../src/corelib/tools/qvarlengtharray.h, line 107
    Invalid parameter passed to C runtime function.
    I have searched, cleaned, ran Qmake, searched some more to no avail. Any ideas?



  • Does the variable printPreview point to a valid QWidget? I don't see that you are setting it anywhere. So your connect statement could be making the emit calls try to do things with invalid memory leading to a crash.



  • Yes it was a typo when I posted the code. The variable is declared. I changed the above posted code to correct how it should have read.



  • But does it also point to a valid object? If it wasn't declared it woudl not compile. If it is declared but pointing at random memory you could get a crash like you are seeing.



  • initialise the variable at top of constructor to 0. The you will see if it's initialised properly



  • There is no variable printPreview in your code, if you modify it, please leave a note, so that readers can follow the discussion.

    Can you show us the code for your slot in Dialog2, please. Also, a stack trace of the crash would be helpful.



  • I assume that the variable is initialized properly as the dialog2 does open when the emit signal is commented out. The dialog opens without a problem but obviously the data is not sent.



  • We know nothing about what is sent or not, as we do not have a stack trace.



  • You have completely changed the code. You are now connecting the signal up to a slot on dialog2 now instead of printPreview.

    Can you please either:

    Provide a complete backtrace as Volker asked or

    upload a tarball of a small compileable example that reproduces the problem

    You will most likely spot the problem yourself in preparing the example.



  • How do I get a stack trace? I am not at a computer with a complier. I will provide the info when I find out how and get back to my computer.
    Here is the code for the slot:
    dialog2.h
    @private slots:
    void createReportTable(QStringList);
    @
    dialog2.cpp
    @void Dialog2::createReportTable(QStringList stringList)
    {
    QStringList reportOptions=stringList;
    printModel= new QSqlRelationalTableModel (this);
    printModel-> setEditStrategy(QSqlTableModel::OnRowChange);
    printModel-> setTable (mTableName);
    printModel-> setRelation (2, QSqlRelation("rider", "id", "LName"));
    printModel-> setRelation (3, QSqlRelation("track", "id", "TrackName"));
    printModel-> setRelation (4, QSqlRelation("bike", "id", "BikeName"));

    //set up printview
    ui->printView->setModel(printModel);
    ui->printView->setItemDelegate(new QSqlRelationalDelegate(this));
    ui->printView->setSelectionMode(QAbstractItemView::SingleSelection);
    ui->printView->setSelectionBehavior(QAbstractItemView::SelectRows);
    ui->printView->setColumnHidden(0,true);
    ui->printView->setColumnHidden(1, true);    
    ui->printView->setColumnHidden(2, true); 
    ui->printView->setColumnHidden(3, true); 
    ui->printView->setColumnHidden(4, true); 
    

    if (reportOptions.at(0)=="FSChecked") {
    printModel->setHeaderData (5, Qt::Horizontal, "Front \n Spring");
    printModel->setHeaderData (6, Qt::Horizontal, "Spring \n Preload");
    printModel->setHeaderData (7, Qt::Horizontal, "Oil \n Weight");
    printModel->setHeaderData (8, Qt::Horizontal, "Oil \n Height");
    printModel->setHeaderData (9, Qt::Horizontal, "Front \n Compression");
    printModel->setHeaderData (10, Qt::Horizontal, "Front \n Rebound");
    printModel->setHeaderData (11, Qt::Horizontal, "Fork \n Tube Height");
    }

    else //hide column and place in labels
    {
            ui->printView->setColumnHidden(5,true); //Front Spring Rate
      ui->printView->setColumnHidden(6,true); //Front Spring Preload
      ui->printView->setColumnHidden(7,true); //Front Oil Weight
      ui->printView->setColumnHidden(8,true); //Oil Height
      ui->printView->setColumnHidden(9,true); //Front Compression
      ui->printView->setColumnHidden(10,true); //Front rebound
      ui->printView->setColumnHidden(11, true); //Fork Tube Height
    
      //Need to place data in lables
    
     
    }
    

    if (reportOptions.at(1)== "FTireChecked") //Front tire changes
    {
    printModel->setHeaderData (12, Qt::Horizontal, "Tire Type");
    printModel->setHeaderData (13, Qt::Horizontal, "Tire \n Pressure");
    printModel->setHeaderData (14, Qt::Horizontal, "Tire \n Modifications");
    }
    else
    {
    //itemColumn +=;
    ui->printView->setColumnHidden(12,true);//Tire Type
    ui->printView->setColumnHidden(13,true);//Tire Pressure
    ui->printView->setColumnHidden(14,true);//Tire Modifications
    }

    printModel->setFilter(mFilterString); //mFilterString is initialized earlier
    printModel->select();

    //Set lables and static data

    }@
    I will get a small compileable example when I get to my computer.



  • If you run your program in an development environment (Qt Creator, Visual Studio or the like), you will get it almost automatically, once the program crashes.

    As you do not give us information about your environment, we cannot help you further on this.



  • I am using QT Creator. I am not getting anything backtrace info. I posted the error messages but I am sure there is more than that in a backtrace. After digging deeper and stepping through the program a million times, I think the problem actually lies in dialog2 when it is creating the table. in particular this line:
    @printModel->setFilter(mFilterString); //mFilterString is initialized earlier @
    I am stepping through it...I think I might get it...if not I will keep you posted
    But if you could give me the info on getting the backtrace, it would be greatly appreciated. Another tool to help me resolve problems.

    Thanks



  • That was the problem! In the string manipulation, there were two single quotes when there should have been a single quote! I would still like the info on getting a backtrace.

    Thanks again



  • When you pause the app in the debugger (either manually or hitting a breakpoint or getting a crash) you should be able to see the call stack in one of the debug panels in qt-creator. From there you can copy it to the clipboard via the context menu.



  • Hello, i have the same problem, it wrote me:
    can't find linker symbol for virtual table for QStandardItem' value foundqEmptyModel()::cleanup' instead

    debugger stopped on:
    @void MyClass::currentChanged ( const QModelIndex & indexCurrent, const QModelIndex & indexPrevious ){
    QStandardItem *current = comparisonModel->item(indexCurrent.row(), 0);
    }@

    i know, im accesing something what didnt exist, because of the message,
    because I have model set on QTreeView, and indexes have children... but how to acces that item, when i have only index?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.