Results 1 to 18 of 18

Thread: browsing application

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2007
    Posts
    29
    Qt products
    Qt3
    Platforms
    Unix/X11
    Thanks
    8

    Default Re: browsing application

    i dont get anythin returned.

    Well I geuss thats indeed what i need, but how to use it?
    I get
    "TypeError: first argument of unbound method QFileDialog.dirPath() must be a QFileDialog instance"
    when i just use it like:
    print QFileDialog.dirPath()
    just to see if it works.

    Qt Code:
    1. def OpenFile(self):
    2. QFileDialog.getOpenFileName("/home/Documents/29-10-07 MiraTest/Browsing app", "UI Files (*.ui)")
    3. print QFileDialog.dirPath()
    4. #print QFileDialog.selectedFile()
    5. #datafile = QFileDialog.selectedFile()
    6. #QFileDialog.ExistingFile()
    7. #datafile = fileSelected()
    8. #datafile=selectedFile()
    9. #datafile = self.lE_file.text().ascii()
    10. #self.lE_file.setText(datafile)
    11. #self.lE_file.insertItem
    To copy to clipboard, switch view to plain text mode 
    As you can see i tried multiple things. I want to name the file that has been chosen as "datafile" and then set this as the text for my lineEdit.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    21
    Thanked 418 Times in 411 Posts

    Default Re: browsing application

    I get
    TypeError: first argument of unbound method QFileDialog.dirPath() must be a QFileDialog instance
    getFileDialog() is a static member - so you don't need an instance of QFileDialog to use it.
    But to use selecteFile() you need an instance of QFileDialog.
    So create a variable of Type QFileDialog, and use it to access all the methods you need.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. The following user says thank you to high_flyer for this useful post:

    nitriles (30th October 2007)

  4. #3
    Join Date
    Sep 2007
    Posts
    29
    Qt products
    Qt3
    Platforms
    Unix/X11
    Thanks
    8

    Default Re: browsing application

    Im not quite sure i completly understand how to do that. Its rather new for me.

  5. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    21
    Thanked 418 Times in 411 Posts

    Default Re: browsing application

    Do what? define a variable?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  6. #5
    Join Date
    Sep 2007
    Posts
    29
    Qt products
    Qt3
    Platforms
    Unix/X11
    Thanks
    8

    Default Re: browsing application

    a variable of Type QFileDialog, and use it to access all the methods you need.

    I dont know what to do here

  7. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    21
    Thanked 418 Times in 411 Posts

    Default Re: browsing application

    Amm...
    I don't know what to answer to that.

    1. define a variable of type QFileDialog. (if you don't know how to do this, you should start by reading the fundamentals of programming in general, and the language you are using - nothing we can help you here with)
    2. use the variable you declared in 1 to access the method - again, if you don't understand this, you lack basic understanding of the programming language you are trying to use, and again, nothing we can help with.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  8. #7
    Join Date
    Jun 2008
    Location
    Bulgaria
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: browsing application

    Just use:
    Qt Code:
    1. filename = QtGui.QFileDialog.getOpenFileName(self)
    To copy to clipboard, switch view to plain text mode 

    When a User selected file is available in filename which is in QString type, you can transform it with str()

Similar Threads

  1. dll + application
    By fpujol in forum Qt Programming
    Replies: 11
    Last Post: 15th April 2007, 18:37
  2. Application deployment problem
    By shapirlex in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 13th April 2007, 00:11
  3. Replies: 3
    Last Post: 8th December 2006, 18:51
  4. Replies: 3
    Last Post: 31st March 2006, 18:38

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.