Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8264779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:34:40+00:00 2026-06-08T04:34:40+00:00

I am working on an application which has a view which generates a report

  • 0

I am working on an application which has a view which generates a report to display to the user. This report is something which I’m needing to filter. Using the SQL support in Qt I’ve tried using QSqlTableModel with its filtering capabilities, but it doesn’t seem to find the view as I get the error “Unable to find table TABLE_NAME”. How does one model a view in Qt? I’ve not been able to find any information specifically on that.

QSqlDatabase connection(Request_Connection("DB Name"));
QSqlTableModel* pStore(new QSqlTableModel(NULL, connection));

if (connect(connection))
    pStore->setTable("ViewName");
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T04:34:42+00:00Added an answer on June 8, 2026 at 4:34 am

    If u have an error “Unable to find table TABLE_NAME” it just means that you are trying to get data from non existing table. Check your database.

    EDIT

    Okay, that’s weird what u have done. It should more looks like this:

    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    db.setHostName("localhost");
    db.setDatabaseName("customdb");
    db.setUserName("root");
    db.setPassword("root");
    if(!db.open())
        QMessageBox::information(this, "Error", "Couldn't open database!");
    

    That’s for open database. In first quotes you have a name of sql which you use. Here you can found all available sql plugins. When you connect to database, you can read some data. If you want to use QSqlTableModel for this, you can do it this way:

    QSqlTableModel *model = new QSqlTableModel(parentObject, db);
    model->setTable("employee");
    model->setEditStrategy(QSqlTableModel::OnManualSubmit);
    model->select();
    model->setHeaderData(0, Qt::Horizontal, tr("Name"));
    model->setHeaderData(1, Qt::Horizontal, tr("Salary"));
    
    QTableView *view = new QTableView;
    view->setModel(model);
    view->hideColumn(0); // don't show the ID
    view->show();
    

    This simple example will load ‘Name’ and ‘Salary’ columns from ’employee’ table and will display it in ‘view’ QTableView. That’s how you should do it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I’m working on an application which has been designed using n-tire application architecture .The
I'm working on an application which has data imported from a foreign (and wholly
I am working on an application which has got some sensitive information. I am
We are working with a PHP application which has no concept of switch-able themes;
I'm writting an application which has to contact a webservice. It's working. But, now
Well, simple question. I'm working with VS2008 on an ASP.NET web application which has
I am currently working on a mobile application with VS2008 which has a capacbility
I am currently working on a web application. I was just wondering which has
I'm working on an ASP.NET web application. There's a bill page which has two
So I'm working through the code in this tutorial which has a small button

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.