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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:21:47+00:00 2026-06-15T04:21:47+00:00

My app has a has a QTreeWidget that takes a QDate in one of

  • 0

My app has a has a QTreeWidget that takes a QDate in one of its columns. Since the columns accept QVariants they can hold practically any kind of data. I’ve found that the TreeWidget must use the actual QDate objects instead of QStrings for the column sorting functionality to work correctly. If I use QStrings for dates, they won’t sort in the proper chronological order but rather by the numerical values of the strings. (which is wrong!) My program supports several date formats: USA Style, European style, and ISO-8601 style. I would like to keep everything consistent throughout the app depending on which date format the user has chosen.

However, I noticed that QDate only displays dates in MM/DD/YYYY format. There’s also a strange bug where the QDate displays MM/DD/YYYY on Windows but the exact same code displays MM/DD/YY on Linux. How can I get the QDate to show dates in YYYY/MM/DD or DD/MM/YYYY format without converting to a QString? It is essential to keep everything in QDate format so I don’t break the column sort function in the QTreeWidget.

Here’s my code that converts the QString to a QDate: (nextitem is a QStringList)

// Convert QString date to QDate to make it sort correctly
                QDate entrydate;
                QString id=nextitem.at(2);

                id=id.remove("/");


                QString datepattern;

                switch(Buffer::date_format){
                case 0: // European
                    datepattern="ddMMyyyy";
                    break;

                case 1: // USA Style
                    datepattern="MMddyyyy";
                    break;

                case 2: // ISO
                    datepattern="yyyyMMdd";
                    break;
                }


                entrydate=QDate::fromString(id,datepattern);
  • 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-15T04:21:48+00:00Added an answer on June 15, 2026 at 4:21 am

    QDate follows the current settings in the operating system. If that setting happens to be MM/DD/YY, then that’s what you’ll get. Note: this is what the user wants. A uniform date format in all applications.

    The setting is also influenced by the current locale settings in the OS. In the USA for example the default would be MM/DD/YY, while in most European countries it’s DD/MM/YY.

    In other words: don’t worry about it. It’s not a bug, it’s a feature. And you shouldn’t try to work around it. Users don’t want their applications ignoring their system settings. If my system is set to display dates in MM/DD/YY, I certainly wouldn’t want your app doing its own thing and showing me dates in YYYY/MM/DD format instead.

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

Sidebar

Related Questions

My app has a GtkFileChooserButton that you can use to open a chooser widget
My app has 5 different relative layouts that it can switch between by using
My app has an options menu that is available in almost all Activities, which
My app has a function where it takes user input and then calls HttpGet
My app has the ability of sharing its content between different instances of the
My app has many controls on its surface, and more are added dynamically at
My app has three tabs, A, B, C that have three distinct activities. Tab
My app has a main screen that the user always starts at, and from
My app has a UITextField , which only works with one language -- English
My app has this one screen requires login, should I make a comment for

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.