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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:05:28+00:00 2026-05-23T00:05:28+00:00

How to store data in QMap & Qlist and retrieve them in QT ?

  • 0

How to store data in QMap & Qlist and retrieve them in QT ?

My requirement is I have Schedule Name which are Monday – Sunday and Schedule Items like “Sunday , 12:00 – 17:30″………

Now I want to have 2 QlistWidget one contains schedule names and other contains Schedule items , now when i select one Schedule name in first listbox corresponding related schedule item gets listed in another listbox.

How can I add items to listwidget using Qmap and Qlist?

How to keep data in memory using it?

  QList<QString> ScheduleItemslist;
     ScheduleItemslist << "Saturday,09:00- 17:30" << "Sunday,10:00- 12:00" << "Sunday,01:30- 17:30" ;

 QList<QString> ScheduleItemslst;
  ScheduleItemslst << "Monday,09:00- 17:30" << "Tuesday,10:00- 12:00" << "Wednesday,01:30- 17:30" ;


QMap<QString,QList<QString> > map;
map["Weekend Plus"] = ScheduleItemslist ;
map["All"] = ScheduleItemslst ;

foreach (QString key, map.keys())
{
    ui->listWidgetTimeSet->addItem (key) ;
}


ui->listWidgetTime->addItems(ScheduleItemslist);

In ItemselectionChanged Event :

QList<QString> ScheduleItemslist;
     ScheduleItemslist << "Saturday,09:00- 17:30" << "Sunday,10:00- 12:00" << "Sunday,01:30- 17:30" ;

  QList<QString> ScheduleItemslst;
    ScheduleItemslst << "Monday,09:00- 17:30" << "Tuesday,10:00- 12:00" << "Wednesday,01:30- 17:30" ;

if(ui->listWidgetTimeSet->currentItem()->text() == "Weekend Plus")
{
    ui->listWidgetTime->addItems(ScheduleItemslist);
}
else if (ui->listWidgetTimeSet->currentItem()->text() == "All")
{
    ui->listWidgetTime->addItems(ScheduleItemslst);
}
  • 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-23T00:05:29+00:00Added an answer on May 23, 2026 at 12:05 am

    You need something like this to store your data.

    //Declare your map
    QMap <QString, QList <QString> > map;
    
    //Populate your map in a function
    void populateMap ()
    {
    
        QList<QString> sundaylist;
        sundaylist<< "Sunday , 12:00 - 17:30" << "Sunday , 18:00 - 20:30";
        map ["Sunday"] = sundaylist;
    
        QList<QString> mondaylist;
        mondaylist<< "Monday , 12:00 - 17:30" << "Monday , 18:00 - 20:30";
        map ["Monday"] = mondaylist        
    }
    
    //Populate list1 with keys in your map
    void populateList1 ()
    {
        list1.addItems (map.keys ());
    }
    
    //This is your slot connected to currentItemChanged  signal of list1
    void list1CurrentItemChanged ( QListWidgetItem * current, QListWidgetItem * previous ) 
    {
        list2.clear ();
        QString key = current->text ();
        list2.addItems (map [key]);
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Selenium has the ability to temporarily store data items and then later retrieve them
I have classes that store data, and methods to go get data for individual
I want to store data in string form to MySQL. I have created the
I have a server where I store data from Mac A and Mac B.
I may have to store some i18n-ed data in my database using XML if
I have been using a plist to store data in my app. I have
I have a large core data store that I dont care about encryption. I
I have a Extjs data store in home page and im getting data from
My winform app uses xml files to store data, where should I store them
I have to store data to isolated storage in memory in such a way

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.