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. QFileDialog File/Directory field gets truncated
Forum Updated to NodeBB v4.3 + New Features

QFileDialog File/Directory field gets truncated

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 1.2k Views
  • 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.
  • R Offline
    R Offline
    Raphy
    wrote on last edited by
    #1

    I happen to have a weird behavior of QFileDialog in my application. It is not consistent across different stations and debug/optimized versions, but it happens still.

    I have a QfileDialog that opens with QFileDialog::ShowDirsOnly option, the 'File name' label at the bottom reads 'Directory:' and displays the current directory name right next to it.
    I then start to type into that filed: "C:" and the file dialog starts to complete the path.
    When doing so, I get a drop-down menu with all directories under "C:".
    Then, I go ahead and type 't', which yields "C:\t", for which the menu below shows: "temp" and "tmp".
    I then go down with the down arrow and stop at "temp".
    As soon as I select 'temp', the directory field reads: "emp", instead of "C:\temp".

    Does any one have any idea why this is happening and how can I resolve, or work-around it?
    The system is Windows 7 and Qt version is 4.5.1.

    Any comment will be appreciated.
    Thanks.

    Ni.SumiN 1 Reply Last reply
    0
    • R Raphy

      I happen to have a weird behavior of QFileDialog in my application. It is not consistent across different stations and debug/optimized versions, but it happens still.

      I have a QfileDialog that opens with QFileDialog::ShowDirsOnly option, the 'File name' label at the bottom reads 'Directory:' and displays the current directory name right next to it.
      I then start to type into that filed: "C:" and the file dialog starts to complete the path.
      When doing so, I get a drop-down menu with all directories under "C:".
      Then, I go ahead and type 't', which yields "C:\t", for which the menu below shows: "temp" and "tmp".
      I then go down with the down arrow and stop at "temp".
      As soon as I select 'temp', the directory field reads: "emp", instead of "C:\temp".

      Does any one have any idea why this is happening and how can I resolve, or work-around it?
      The system is Windows 7 and Qt version is 4.5.1.

      Any comment will be appreciated.
      Thanks.

      Ni.SumiN Offline
      Ni.SumiN Offline
      Ni.Sumi
      wrote on last edited by Ni.Sumi
      #2

      @Raphy

      If possible, post the piece of the code. It would be easy to find the error. :)

      Edit:

      Mostly these couple of lines will do , what you are looking.

      QString file = QFileDialog::getOpenFileName();
       QDir dir = QFileInfo(file).absoluteDir();
      qDebug() << dir;
      
      R 2 Replies Last reply
      0
      • Ni.SumiN Ni.Sumi

        @Raphy

        If possible, post the piece of the code. It would be easy to find the error. :)

        Edit:

        Mostly these couple of lines will do , what you are looking.

        QString file = QFileDialog::getOpenFileName();
         QDir dir = QFileInfo(file).absoluteDir();
        qDebug() << dir;
        
        R Offline
        R Offline
        Raphy
        wrote on last edited by
        #3

        @Ni.Sumi
        Thank you for your reply.
        I may have not explained well the problem. The strange behavior I described is inside QFileDialog,
        not after it is closed. It is a weird behavior that occurs while trying to select a directory. There seems to be no interference in QFileDialog behavior from the outside. I have other such dialogs in other parts of my application and they behave properly.
        I was thinking that if someone else came across this kind of behavior and figured out what went wrong, that could give me a hint as for where to look into.

        1 Reply Last reply
        0
        • Ni.SumiN Ni.Sumi

          @Raphy

          If possible, post the piece of the code. It would be easy to find the error. :)

          Edit:

          Mostly these couple of lines will do , what you are looking.

          QString file = QFileDialog::getOpenFileName();
           QDir dir = QFileInfo(file).absoluteDir();
          qDebug() << dir;
          
          R Offline
          R Offline
          Raphy
          wrote on last edited by Raphy
          #4

          @Ni.Sumi said in QFileDialog File/Directory field gets truncated:

          are

          The code creating that dialog is:

          QFileDialog *fd = new QFileDialog();
          fd->setNameFilters(filtersList); // QStringList filterList...
          fd->setDirectory(tmp); // QString tmp...
          fd->setWindowTitle(QString("Open Directory"));
          fd->setFileMode(QFileDialog::Directory);
          fd->setOption(QFileDialog::ShowDirsOnly, true);
          fd->setAcceptMode(QFileDialog::AcceptOpen);
          fd->exec();

          If pictures may help, please let me know how to upload them (could not find a way to do that).

          Thanks.

          1 Reply Last reply
          0

          • Login

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