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 7437715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:26:31+00:00 2026-05-29T10:26:31+00:00

I am student programmer and I am using Qt to develop a GUI interface

  • 0

I am student programmer and I am using Qt to develop a GUI interface for work and Im having trouble figuring out how I should make this this import function work. A bit of programmers writers block if you will. SO far I have this for code:

void InjectionLocationsDialogExpanded::importCSVFile()
{
    QString fileName = QFileDialog::getOpenFileName(this, ("Open File"), "/home", ("csv File(*.csv)"));
    QString data;
    QFile importedCSV(fileName);
    QStringList rowOfData;
    QStringList rowData;
    int tempint = 0;
    data.clear();
    rowOfData.clear();
    rowData.clear();
    if (importedCSV.open(QFile::ReadOnly))
    {
        data = importedCSV.readAll();
        rowOfData = data.split("\n");
        rowData = data.split(";");
        importedCSV.close();
    }
    qDebug() << data;
    for (int x = 0; x < rowOfData.size(); x++)
    {
        for (int y = 0; y < ui->tableWidgetInjectionLocationsExpandedDialog->columnCount(); y++)
        {
            ui->tableWidgetInjectionLocationsExpandedDialog->item(x,y)->setText(rowData[]);
        }
    }
}

The issue here is that I don’t know how to get the settext of each item in the table to reference the next item in the rowData QStringList. I need to increment by one location but I cant use a int++ because that will eventually look for a item in the QStringList that doesn’t exist and cause a segmentation fault. I also cant use a for loop to cap the number I need in the location field here because of the current for loops structure. I just cant think of a good strategy for to approach this on. Please only leave constructive comments as I am only interested in learning or accomplishing this task. Thanks for reading!

  • 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-05-29T10:26:32+00:00Added an answer on May 29, 2026 at 10:26 am

    First of all, you would need to take care of line endings.
    This means that your code might not be platform independent if you just check for “\n” in your CSV file.

    If I get what you’re trying to do, you would have to set the rowData within the for-loop.
    So, what I would do then :

    rowOfData.clear();
    rowData.clear();
    
    if (importedCSV.open(QFile::ReadOnly))
    {
        data = importedCSV.readAll();
        rowOfData = data.split("\n");
        importedCSV.close();
    }
    
    for (int x = 0; x < rowOfData.size(); x++)
    {
        rowData = rowOfData.at(x).split(";");
        for (int y = 0; y < rowData.size(); y++)
        {
            ui->tableWidgetInjectionLocationsExpandedDialog->item(x,y)->setText(rowData[y]);
        }
    }
    

    I guess this should do it.
    Best regards.

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

Sidebar

Related Questions

Im a student programmer using Qt to develop a GUI for work and I
I am a student programmer using Qt to develop a GUI application. I am
I am a student programmer using Qt to build a GUI for work. I
I am currently a student programmer using Qt to build a GUI inteface at
I'm a student programmer and I am using Qt to build some GUI applications
I am a student programmer and I am using Qt to build a GUI
I'm a student programmer and I am using Qt to build a GUI for
I'm a student programmer and I'm using Qt to create a Gui that gets
I'm a student programmer and I am using Qt to build a GUI application.
I am a student programmer currently designing a GUI for my company with Qt

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.