Qt C ++我想用MainWindow将数据传递给项目窗口,但我得到错误:LNK2019

时间:2017-05-26 12:14:32

标签: c++ qt

我想将MainWindow的数据传递给项目窗口,但是我收到错误:

  

moc_form.obj:-1:错误:LNK2019:未解析的外部符号“public:   void __cdecl Form :: getItemID(class QString)“   (?getItemID @ Form @@ QEAAXVQString @@@ Z)在函数“private”中引用:   static void __cdecl Form :: qt_static_metacall(class QObject *,enum   QMetaObject :: Call,int,void * *)“   (?qt_static_metacall @ @@表格@@ CAXPEAVQObject @ W4Call @@ QMetaObject @ HPEAPEAX Z)

MainWindow.h

signals:
    void sendData(QString str);
private slots:
    void on_tableView_doubleClicked(const QModelIndex &index);

private:
    DialogItem *myform;

MainWindow.cpp

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{

    myform = new DialogItem();
    connect(this, SIGNAL(sendData(QString)), myform, SLOT(getItemID(QString)));
}

void MainWindow::on_tableView_doubleClicked(const QModelIndex &index)
{
 //   int row = index.row();
    QModelIndex mi = table->currentIndex() ;
    QString selectedItemName = table->model()->data(mi).toString();
//    QString str = index.data().toString();


    table->setSelectionBehavior(QAbstractItemView::SelectRows);
    QModelIndex currentDiscount  = ui->tableView->currentIndex();
    emit sendData(table->model()->data(table->model()->index(currentDiscount.row(),1),0));
    qDebug() << table->model()->data(table->model()->index(currentDiscount.row(),1),0);

    qDebug() << table->model()->index( table->currentIndex().row(), 0 ).data().toInt();

    DialogItem *dialog = new DialogItem;
    dialog->show();
}

dialogItem.h

public slots:
    void DescriptionItem();
    vector<QString> getItemID(QString partNumber);

dialogItem.cpp

vector<QString> DialogItem::getItemID(QString partNumber);
{
    vector<QString> descriptionItem;

    QSqlQuery query;
    QString sstr = "SELECT * FROM \"" + tableName + "\" WHERE \"" + Part Number + "\" = \'" + partNumber + "\'"
    query.exec(sstr);

    while (query.next())
    {
        QString value = query.value(0).toString();
        tableNames.push_back(value);
    }

    return descriptionItem;
}

0 个答案:

没有答案