Results 1 to 18 of 18

Thread: browsing application

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

    Default browsing application

    Hello,

    I want to create a browse app. Just a browse button, where when clicked, opens a window for browsing and displays the file name (or the whole link) in a lineedit. I know that there is QFileDialog, but since im quite new, i dont understand that. And all the info that i found was written in C++, which i really dont get, im using Python.
    Hope someone can help me!
    Thanks

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

    Default Re: browsing application

    Hope someone can help me!
    With what?
    We can't tell you things that are not in the docs.
    There is no way around starting, and trying.
    Then, when you get stuck, you will have a specific question about where you got stuck.
    Post it here, and we will try to help you.

    Good luck.

    P.S
    If I remember right, there is an example that comes with Qt which does exactly what you want.
    ==========================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. #3
    Join Date
    Sep 2007
    Posts
    29
    Thanks
    8
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: browsing application

    ok i agree my question was kinda vague!
    I have a program which subplots 10 data using matplotlib.
    It is ran by typing in the console:
    python plotdata.py DataFile.csv
    If i do not type DataFile.csv then it doesn't run the program but says, please enter file name.
    What i want is to create a small form with Qt with a line edit (where the file name should be), a browse button (which opens a browse window to select the file which is later displayed in the line edit) a cancel button to close and a Plot button which launches my plotdata.py file and plots graphs using the datafile that was chosen.
    I hope this is clear. My problem is that i dont know how to create a browse button.
    I didn't look into the programming of launchin my python program, but i think that it should be something with exec_file(plotdata.py).

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

    Default Re: browsing application

    I hope this is clear. My problem is that i dont know how to create a browse button.
    You were clear the last time too.
    But what do expect as an answer?
    If you can read our answer on how to do this, you can just as well read it in the docs, where it is for sure better explained.
    Unless of course you have a specific question.

    If I understand you correctly, you want a small GUI program, that will feed your console program with the fine name you chose through the GUI.
    You can create the GUI it self with Designer.
    You can then make a small programm that feeds the selcted file name by using QProcess.

    You should look at PyQt for using Qt with Python, sadly, I am C++ coder and can't help you with that (may be others on the forum?).
    ==========================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.

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

    nitriles (26th October 2007)

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

    Default Re: browsing application

    Well i have searched, but failed. What i did find is C++ examples, which i dont understand. But yeah, u did understand me correctly
    -btw: im also in Munich, garching

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

    Default Re: browsing application

    google is your friend
    http://www.cs.usfca.edu/~afedosov/qttut/
    (there are many others)

    (I am in the South - Sendling )
    ==========================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
    Sep 2007
    Posts
    29
    Thanks
    8
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: browsing application

    Thanks, thats the site where I learned PyQt.
    But the problem is that i dont know how to write the code that when the button Browse is clicked, that it opens a window where a file can be selected.
    I created a form with Qt, know i just need to create some signals and slots. I wished there was a browse widget.

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

    Default Re: browsing application

    I wished there was a browse widget.
    But there is: QFileDialog
    ==========================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.

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

    Default Re: browsing application

    aha!
    yes, well ill look into that, thanks a lot.

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

    Default Re: browsing application

    Yippi, i managed to get a popup by just saying:
    Qt Code:
    1. def OpenFile(self):
    2. QFileDialog.getOpenFileName()
    To copy to clipboard, switch view to plain text mode 

    But now im having trouble with selecting the file. When the user has selected a file and clicks open, i want the file path including its name to be printed in a lineEdit_box.
    I tried using:
    Qt Code:
    1. datafile = fileSelected() OR datafile=selectedFile()
    2. self.lE_file.setText(datafile)
    To copy to clipboard, switch view to plain text mode 
    But this didnt work. Does anybody have any ideas?

    NameError: global name 'selectedFile' is not defined

    Thanks!
    Last edited by nitriles; 30th October 2007 at 11:34.

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

    Default Re: browsing application

    QFileDialog::dirPath()?
    although selectedFile() should work.
    What do you mean "doesn't work"?
    What do you get in the returned string?
    ==========================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.

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

    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.

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

    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.

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

    nitriles (30th October 2007)

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

    Default Re: browsing application

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

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

    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.

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

    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

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

    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.

  20. #18
    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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.