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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:34:27+00:00 2026-05-12T19:34:27+00:00

I have a open file dialog with three filters: QString fileName = QFileDialog::getOpenFileName( this,

  • 0

I have a open file dialog with three filters:

QString fileName = QFileDialog::getOpenFileName(
        this,
        title,
        directory,
        tr("JPEG (*.jpg *.jpeg);; TIFF (*.tif);; All files (*.*)")
);

This displays a dialog with “JPEG” selected as the default filter. I wanted to put the filter list in alphabetical order so “All files” was first in the list. If I do this however, “All files” is the default selected filter – which I don’t want.

Can I set the default selected filter for this dialog or do I have to go with the first specified filter?

I tried specifying a 5th argument (QString) to set the default selected filter but this didn’t work. I think this might only be used to retrieve the filter that was set by the user.

  • 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-12T19:34:27+00:00Added an answer on May 12, 2026 at 7:34 pm

    Like this:

    QString selfilter = tr("JPEG (*.jpg *.jpeg)");
    QString fileName = QFileDialog::getOpenFileName(
            this,
            title,
            directory,
            tr("All files (*.*);;JPEG (*.jpg *.jpeg);;TIFF (*.tif)" ),
            &selfilter 
    );
    

    The docs are a bit vague about this, so I found this out via guessing.

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

Sidebar

Related Questions

I want to open a save file dialog, have the user enter a filename,
I have main window with button open file. On clicking file selector dialog shows
I'm using this PHP code on a file to open a dialog box to
Suppose I have an open file. How can I detect when the file is
In php I have open a .php file and want to evaluate certain lines.
I have the following code: using (BinaryReader br = new BinaryReader( File.Open(FILE_PATH, FileMode.Open, FileAccess.ReadWrite)))
I have a program which needs to hold approximately 3000 open file descriptors in
I have: <?php $file=fopen(date(Y-m-d)..txt,r+) or exit(Unable to open file!); if ($_POST[lastname] <> ) {
I have tried to open a PDF file from the local disk. For example
Building a file open dialog replacement. Much of it works now, but I would

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.