Results 1 to 10 of 10

Thread: File browser

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2006
    Posts
    5
    Thanks
    1

    Default Re: File browser

    Quote Originally Posted by jpn
    ... You are only changing the listbox contents in constructor and when an item is activated. You are not changing the listbox contents when a paint event occurs.
    OK then, if update is not updating and unless Qt is capable of faking events, Qt promises to be a fairly unwieldy scripting language!
    Last edited by jp; 18th July 2006 at 17:15.

  2. #2
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: File browser

    Quote Originally Posted by jp
    OK then, if update is not updating and unless Qt is capable of faking events, Qt promises to be a fairly unwieldy scripting language!
    Hmmm, two things:
    1. Qt is capable of faking certain events.
    2. Qt is not a scripting language.
    Save yourself some pain. Learn C++ before learning Qt.

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: File browser

    Quote Originally Posted by jp
    OK then, if update is not updating and unless Qt is capable of faking events, Qt promises to be a fairly unwieldy scripting language!
    No offense, but the problem is not at all within Qt. The problem lies in your code structure. Let's make this clear. How do you expect the list box to change it's contents after calling update()? It will just redraw earlierly inserted items. You need to pass the current dir from the line edit to the list box and change the contents.

    To make this work, your code should look more like this:

    Qt Code:
    1. void CListBox::onActivation(QListWidgetItem *item)
    2. {
    3. setDir(item->text());
    4. }
    5.  
    6. void CListBox::setDir(const QString& dir)
    7. {
    8. QFileInfo fiche(dir);
    9. ...
    10. for (...)
    11. insertItem(...)
    12. ...
    13. emit dirChanged(dir);
    14. }
    15.  
    16. void CLineEdit::onReturnPressed()
    17. {
    18. emit dirChanged(text());
    19. }
    20.  
    21. QObject::connect(&lbox, SIGNAL(dirChanged(const QString&)), &ledit, SLOT(setText(const QString&)));
    22. QObject::connect(&ledit, SIGNAL(dirChanged(const QString&)), &lbox, SLOT(setDir(const QString&)));
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  4. #4
    Join Date
    Mar 2006
    Posts
    5
    Thanks
    1

    Default Re: File browser

    Thanks jpn and Chicken Blood Machine.
    I was simply under the misguided impression that one could write compact code without the benefit of using the QDirModel class.

Similar Threads

  1. Suggestions/Ideas about a file browser
    By SkripT in forum Qt Programming
    Replies: 31
    Last Post: 6th April 2011, 23:17
  2. Draging a non-existing file to the Windows Desktop
    By klaus1111 in forum Qt Programming
    Replies: 13
    Last Post: 20th September 2007, 11:47
  3. Replies: 11
    Last Post: 4th July 2006, 15:09
  4. File permission QFile::WriteOther on Win Dos
    By patrik08 in forum Newbie
    Replies: 1
    Last Post: 13th June 2006, 14:16
  5. Opening swf file in the default browser
    By munna in forum Qt Programming
    Replies: 16
    Last Post: 5th May 2006, 09:33

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.