Results 1 to 2 of 2

Thread: QDiaglog, getting the error: ..."was not declared in this scope"

  1. #1
    Join Date
    Jun 2015
    Posts
    28
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default QDiaglog, getting the error: ..."was not declared in this scope"

    hello buddies,
    I'm trying to implement a QDialog to update data retrieved from a QTableView, so I'm doing this:


    Qt Code:
    1. #include <QDialog>
    2. void MainWindow::on_tvMain_doubleClicked(const QModelIndex &index)
    3. {
    4. QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    5. db.setDatabaseName("agenda");
    6. db.open();
    7.  
    8. QSqlTableModel *model = new QSqlTableModel(this, db);
    9. model->setTable("departamentos");
    10. model->setEditStrategy(QSqlTableModel::OnFieldChange);
    11. model->select();
    12. QSqlRecord rec = model->record();
    13.  
    14. QModelIndex sample = ui->tvMain->currentIndex();
    15. if (sample.row() >= 0 ) {
    16. QSqlRecord rec = model->record(sample.row());
    17. NewContact dlg(this);
    18. dlg.setNome(rec.value("NOME").toString());
    19. dlg.setSigla(rec.value("SIGLA").toString());
    20.  
    21. if (dlg.exec() == QDialog::Accepted) {
    22. rec.setValue("NOME",dlg.nome());
    23. rec.setValue("SIGLA",dlg.sigla());
    24. model->setRecord(sample.row(),rec);
    25. }
    26. }
    27. }
    To copy to clipboard, switch view to plain text mode 

    But i'm getting the following error in line 17:

    /home/elementaryos/Projetos/Agenda/Agenda/mainwindow.cpp:78: error: 'NewContact' was not declared in this scope
    NewContact dlg(this);
    ^
    /home/elementaryos/Projetos/Agenda/Agenda/mainwindow.cpp:78: error: expected ';' before 'dlg'
    NewContact dlg(this);
    ^
    /home/elementaryos/Projetos/Agenda/Agenda/mainwindow.cpp:79: error: 'dlg' was not declared in this scope
    dlg.setName(rec.value("name").toString());
    ^
    I've read various threads in this forum, on internet and in qt documentation, but i can't solve this. Can any one give some light?

    thanks,
    Juliano
    Last edited by juliano.gomes; 2nd June 2015 at 19:37. Reason: forgot to thanks

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QDiaglog, getting the error: ..."was not declared in this scope"

    Basic C++ - you need to include the header with "NewContact" class declaration.

Similar Threads

  1. Replies: 3
    Last Post: 27th January 2013, 23:53
  2. Replies: 32
    Last Post: 25th August 2012, 23:10
  3. Replies: 2
    Last Post: 28th February 2010, 07:38
  4. "Treat wchar_t as Built-in Type" to "yes" link error
    By sungaoyong in forum Qt Programming
    Replies: 1
    Last Post: 5th June 2008, 11:45
  5. QFile Problem~ "Unknow error" in "open(QIODevice::ReadWrite)"
    By fengtian.we in forum Qt Programming
    Replies: 3
    Last Post: 23rd May 2007, 15:58

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.