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. [SOLVED] .getSaveFileName doesn't work in Qgis
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] .getSaveFileName doesn't work in Qgis

Scheduled Pinned Locked Moved Unsolved General and Desktop
qgisgetsavefilename
3 Posts 2 Posters 1.6k 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.
  • Agat BA Offline
    Agat BA Offline
    Agat B
    wrote on last edited by Agat B
    #1

    Hi guys, I'm beginner in Qt and I got stuck on probably very simple problem. So, here is my code:

     def select_output_file(self):
    		filename = QtGui.QFileDialog.getSaveFileName(self, "Select output file ","", '*.txt')
    		self.dlg.lineEdit.setText(filename)
    		
    		self.dlg.lineEdit.clear()
    		self.dlg.pushButton.clicked.connect(self.select_output_file)
    

    The problem is, that I don't know the error- everything is pretending to be ok, but the push button doesn't work. I click on it and almost nothing happens- it is active, but there is no action. I saw similar problem with solution on stackexchanege, but nothing works in my case. I imported needed stuff from QtGui library. And I have no idea what's going on.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      asanka424
      wrote on last edited by
      #2

      I have no experience in Qgis. But you code snippet seems like a python code. According to your code your connections is never set since you are connectig to the slot in slot function. (the last line). You have to make your connections before signals are fired. Otherwise they wont be catched in slot functins.

      I suggest move you connect line into the constructor.

      Agat BA 1 Reply Last reply
      1
      • A asanka424

        I have no experience in Qgis. But you code snippet seems like a python code. According to your code your connections is never set since you are connectig to the slot in slot function. (the last line). You have to make your connections before signals are fired. Otherwise they wont be catched in slot functins.

        I suggest move you connect line into the constructor.

        Agat BA Offline
        Agat BA Offline
        Agat B
        wrote on last edited by
        #3

        @asanka424 Thanks a lot! Your suggestion works. After moving the connect line into the constructor, I also needed to change this:

        filename = QFileDialog.getSaveFileName(self, "Select output file ","", '*.txt')
        

        to this:

        filename = QFileDialog.getSaveFileName(None, "Select output file ","", '*.txt')
        
        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