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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:09:10+00:00 2026-05-28T01:09:10+00:00

I am compiling on Linux with Qt Creator. I already finished the basics of

  • 0

I am compiling on Linux with Qt Creator. I already finished the basics of my GUI with the Qt Designer. Now I need to know if there is a method available that opens the file manager and let me create a directory named by me?

I found this:

QFileDialog dialog(this);
dialog.setFileMode(QFileDialog::AnyFile);

(see http://doc.qt.io/archives/qt-4.7/qfiledialog.html#directory)

I have connected a QPushButton with a method and wrote the above into it.
Problems are: The file manager does not even open when I push the Button. Furthermore this should only work for creating not existent files (see AnyFile), but I need to create a not existing directory.

I also know this possibility for creating a directory:

QDir("/home/name").mkdir("NewDirectory");

But this does not fulfill my demands since the name and the directory are always the same.

  • 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-28T01:09:11+00:00Added an answer on May 28, 2026 at 1:09 am

    Here’s for solving the problem with the nonexistent folders / files:

    You need some Variables:

    QString path_trunk;
    QString name;
    

    and in the Slot that is being called by your button you’ll have to adjust the parameters so that they suit your demands, for. e.g. you may use the parameters being handed down through the button or being manipulated by some internal events. In that case you could of course create folders dynamically through using the variables:

    path_trunk = QString("/home/username/");
    name = QString("Folder_name");
    
    QDir(path_trunk).mkdir(name);
    

    Another, more user friendly way would be to fetch values from the UI through a line/text edit element which allows the user to enter a custom path. You can read the values through the UI class ( here I just used the standard QT name ui). The name lineEdit can be different in your case if you chose to name it differently. But you can access the data nevertheless and use id dynamically in your underlying Code. Make sure to connect your signals and methods properly.

    void MainWindow::on_pushButton_clicked_path_dynamic()
    {
        QString temp_path = ui->lineEdit->text();
        QDir().mkdir(temp_path);
    }
    
    void MainWindow::on_pushButton_clicked_trunk_plus_dynamic()
    {
        QString ext_path = ui->lineEdit->text();
        QDir(path_trunk).mkdir(ext_path);
    }
    

    Here’s another approach, since from my understanding you want to use some sort of File Manager:

    What you actually could do would be to create your own File Manager Widget. The QDir Method basically gives you all the information you need for displaying a folder incl. files in some Item-based QTreeWidget, Navigation through that would also be an easy task since you can use the signals and slots of the QTreeWidget to navigate, you would just have to fill the Tree with your folder Information. Creating a new folder would then only be a user interaction(right mouse button or maybe clicking a QPushButton “Create Folder” in your custom File Manager Widget)

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

Sidebar

Related Questions

I am compiling my program that will run on linux gcc 4.4.1 C99. I
Is there a manual for cross-compiling a C++ application from Linux to Windows? Just
I have heard that setting the --prefix=PREFIX option when compiling PHP on linux will
I'm compiling an example program that uses opengl in ubuntu (linux). A short snippet
I already have my program compiling on the linux gcj, but i'd like to
I am compiling under Linux (GCC 4.4.2) and Windows VS C++ Express Edition 2008
I am interested in cross-compiling a Linux kernel for an ARM target on a
Compiling a kernel module on 32-Bit Linux kernel results in __udivdi3 [mymodule.ko] undefined! __umoddi3
When compiling with gmcs on Linux, how can I set the explorer icon the
when compiling some projects on linux terminal, I get usually a long output consisting

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.