Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Kubuntu 22.04 - Open File Dialog - Can we have access to the controls?
Forum Updated to NodeBB v4.3 + New Features

Kubuntu 22.04 - Open File Dialog - Can we have access to the controls?

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 456 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    stretchthebits
    wrote on last edited by
    #1

    I am on Kubuntu 22.04.

    I use QFileDialog to create an Open File dialog box.
    There are EDITBOXes, COMBO BOXes, BUTTONs on the dialog box.
    Can we have access to those controls and maybe disable them or change their properties?

    For example, I would like make the file filter a non editable COMBOBOX. In other words, I don’t want the user to be able to type in it as if it was a EDITBOX.
    I want it to be just a COMBOBOX. The user can only drop the list and select something.

    fileFilter="Text files - *.txt (*.txt)";
    selectedFilter="Text files - *.txt (*.txt)";
    aDlg=new QFileDialog(this, "Open Text File", pFolderPath_WordsFile, fileFilter);
    aDlg->setFilter(QDir::NoDotAndDotDot | QDir::AllDirs | QDir::Files);
    aDlg->selectNameFilter(selectedFilter);
    aDlg->setFileMode(QFileDialog::ExistingFile);
    aDlg->setOption(QFileDialog::DontUseNativeDialog, true);
    
    aDlg->exec();
    

    Also, is there is Linux specific subforum?

    JonBJ 1 Reply Last reply
    0
    • S stretchthebits

      I am on Kubuntu 22.04.

      I use QFileDialog to create an Open File dialog box.
      There are EDITBOXes, COMBO BOXes, BUTTONs on the dialog box.
      Can we have access to those controls and maybe disable them or change their properties?

      For example, I would like make the file filter a non editable COMBOBOX. In other words, I don’t want the user to be able to type in it as if it was a EDITBOX.
      I want it to be just a COMBOBOX. The user can only drop the list and select something.

      fileFilter="Text files - *.txt (*.txt)";
      selectedFilter="Text files - *.txt (*.txt)";
      aDlg=new QFileDialog(this, "Open Text File", pFolderPath_WordsFile, fileFilter);
      aDlg->setFilter(QDir::NoDotAndDotDot | QDir::AllDirs | QDir::Files);
      aDlg->selectNameFilter(selectedFilter);
      aDlg->setFileMode(QFileDialog::ExistingFile);
      aDlg->setOption(QFileDialog::DontUseNativeDialog, true);
      
      aDlg->exec();
      

      Also, is there is Linux specific subforum?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @stretchthebits
      Did you try QObject::findChildren<>() to see if you can access widgets?

      1 Reply Last reply
      0
      • S Offline
        S Offline
        stretchthebits
        wrote on last edited by
        #3

        I tried this. It compiles and runs fine but it has no effect on the COMBOX.

        QList<QComboBox *> allComboBoxes=aDlg->findChildren<QComboBox *>();
        for(i=0; i<allComboBoxes.size(); i++)
        {
           allComboBoxes[i]->setEditable(false);
        }
        
        JonBJ M 2 Replies Last reply
        0
        • S stretchthebits

          I tried this. It compiles and runs fine but it has no effect on the COMBOX.

          QList<QComboBox *> allComboBoxes=aDlg->findChildren<QComboBox *>();
          for(i=0; i<allComboBoxes.size(); i++)
          {
             allComboBoxes[i]->setEditable(false);
          }
          
          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @stretchthebits
          If they don't expose whatever they are using, and if they are not found as QWidgets (try doing a aDlg->findChildren<QWidget *>() to see everything they have there), then I don't know how you access stuff on this dialog. You could look at the source code.....

          S 1 Reply Last reply
          0
          • S stretchthebits

            I tried this. It compiles and runs fine but it has no effect on the COMBOX.

            QList<QComboBox *> allComboBoxes=aDlg->findChildren<QComboBox *>();
            for(i=0; i<allComboBoxes.size(); i++)
            {
               allComboBoxes[i]->setEditable(false);
            }
            
            M Offline
            M Offline
            mpergand
            wrote on last edited by mpergand
            #5

            @stretchthebits
            Test with Kubuntu 21.04 Qt 5.12.11

            QString fileFilter="Text files - *.txt (*.txt)";
                QString selectedFilter="Text files - *.txt (*.txt)";
                auto aDlg=new QFileDialog(nullptr, "Open Text File", "", fileFilter);
                aDlg->setFilter(QDir::NoDotAndDotDot | QDir::AllDirs | QDir::Files);
                aDlg->selectNameFilter(selectedFilter);
                aDlg->setFileMode(QFileDialog::ExistingFile);
                aDlg->setOption(QFileDialog::DontUseNativeDialog, true);
            
                for(int i=0; i<aDlg->layout()->count(); i++)
                    {
                    QLayoutItem *item=aDlg->layout()->itemAt(i);
                    qDebug()<<item->widget();
                    }
            /*
            QLabel(0x5577e38ca3c0, name="lookInLabel")
            QWidget(0x0)
            QSplitter(0x5577e38cd160, name="splitter")
            QLabel(0x5577e38d9d30, name="fileNameLabel")
            QLineEdit(0x5577e38da130, name="fileNameEdit")
            QDialogButtonBox(0x5577e39e2390, name="buttonBox")
            QLabel(0x5577e39e4630, name="fileTypeLabel")
            QComboBox(0x5577e398c620, name="fileTypeCombo")
            
            */
            
                QList<QComboBox*> allComboBoxes=aDlg->findChildren<QComboBox*>("fileTypeCombo");
                if(allComboBoxes.count())
                    {
                    QComboBox *combo=allComboBoxes.at(0);
                    combo->setEditable(false);
                    // combo->setEditable(true);  // now editable (not editable by default for me)
                    qDebug()<<combo;
                    }
            
            1 Reply Last reply
            0
            • JonBJ JonB

              @stretchthebits
              If they don't expose whatever they are using, and if they are not found as QWidgets (try doing a aDlg->findChildren<QWidget *>() to see everything they have there), then I don't know how you access stuff on this dialog. You could look at the source code.....

              S Offline
              S Offline
              stretchthebits
              wrote on last edited by
              #6

              @JonB
              QList<QComboBox *> allComboBoxes=aDlg->findChildren<QComboBox *>();
              does return 2 COMBOBOXes.
              The first is called
              lookInCombo.
              I think this is the COMBOBOX for choosing your folder.

              The second is called
              fileTypeCombo
              I think this is the COMBOBOX for choosing your file filter.

              We can see this in what mpergand posted.

              Also, what is the difference between
              aDlg->setOption(QFileDialog::DontUseNativeDialog, true);
              and
              aDlg->setOption(QFileDialog::DontUseNativeDialog, false);

              In both cases, the dialog box looks nearly identical (but not exactly) except that when “true”, the file filter COMBOBOX is not editable.

              I tried mpergand’s code. Yes, there is a single COMBOBOX called
              fileTypeCombo

              but it still seems not possible to set it as non-editable.

              The only solution seems to be to call the magical function:
              aDlg->setOption(QFileDialog::DontUseNativeDialog, true);

              JonBJ 1 Reply Last reply
              0
              • S stretchthebits

                @JonB
                QList<QComboBox *> allComboBoxes=aDlg->findChildren<QComboBox *>();
                does return 2 COMBOBOXes.
                The first is called
                lookInCombo.
                I think this is the COMBOBOX for choosing your folder.

                The second is called
                fileTypeCombo
                I think this is the COMBOBOX for choosing your file filter.

                We can see this in what mpergand posted.

                Also, what is the difference between
                aDlg->setOption(QFileDialog::DontUseNativeDialog, true);
                and
                aDlg->setOption(QFileDialog::DontUseNativeDialog, false);

                In both cases, the dialog box looks nearly identical (but not exactly) except that when “true”, the file filter COMBOBOX is not editable.

                I tried mpergand’s code. Yes, there is a single COMBOBOX called
                fileTypeCombo

                but it still seems not possible to set it as non-editable.

                The only solution seems to be to call the magical function:
                aDlg->setOption(QFileDialog::DontUseNativeDialog, true);

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by
                #7

                @stretchthebits said in Kubuntu 22.04 - Open File Dialog - Can we have access to the controls?:

                Also, what is the difference between
                aDlg->setOption(QFileDialog::DontUseNativeDialog, true);
                and
                aDlg->setOption(QFileDialog::DontUseNativeDialog, false);

                The first uses a Qt file chooser dialog, the second whatever "native" one is available, see the docs. They may or may not be similar. On the native one you can only do whatever it allows, e.g. maybe it has a combobox but ignores non-editable and only the Qt one does allow that.

                1 Reply Last reply
                1

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved