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. Single Click Event on Q
Qt 6.11 is out! See what's new in the release blog

Single Click Event on Q

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 709 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.
  • L Offline
    L Offline
    LT-K101
    wrote on last edited by
    #1

    I have data in a QTableWidget and I want a function to perform a single click on the first record and display the first item in the QTableWiget in a QLabel. Below is the function code. But the application exit when I run the code, I need assistance please. Thanks in Advance.

      ## Data source Name is EmployeeList ###
    self.Staff_Summary_tableWidget.itemclicked.connect(self.single_click)
    
    def single_click(self):
    
                # print(employees)
                staff_no_display = self.ui.Staff_No_label.setText(employeeList[0])
                employeeList = self.ui.Staff_Summary_tableWidget.currentItem().text()
    
          
    
    
    JonBJ 1 Reply Last reply
    0
    • L LT-K101

      I have data in a QTableWidget and I want a function to perform a single click on the first record and display the first item in the QTableWiget in a QLabel. Below is the function code. But the application exit when I run the code, I need assistance please. Thanks in Advance.

        ## Data source Name is EmployeeList ###
      self.Staff_Summary_tableWidget.itemclicked.connect(self.single_click)
      
      def single_click(self):
      
                  # print(employees)
                  staff_no_display = self.ui.Staff_No_label.setText(employeeList[0])
                  employeeList = self.ui.Staff_Summary_tableWidget.currentItem().text()
      
            
      
      
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @LT-K101
      This is not a full application, just an extract.

      Presumably if "the application exits" on a click there is an error, and you get an error message somewhere.

      Your slot code in itself does nothing other than set two local variables. I do not know whether employeeList[0] is valid, nor whether in Staff_Summary_tableWidget.currentItem().text() there is indeed a current item set for currentItem() to return.

      L JonBJ 2 Replies Last reply
      3
      • JonBJ JonB

        @LT-K101
        This is not a full application, just an extract.

        Presumably if "the application exits" on a click there is an error, and you get an error message somewhere.

        Your slot code in itself does nothing other than set two local variables. I do not know whether employeeList[0] is valid, nor whether in Staff_Summary_tableWidget.currentItem().text() there is indeed a current item set for currentItem() to return.

        L Offline
        L Offline
        LT-K101
        wrote on last edited by
        #3

        @JonB You are right, employeeList[0] is valid and in the Staff_Summary_tableWidget.currentItem().text() there is a current item set to return.

        1 Reply Last reply
        0
        • JonBJ JonB

          @LT-K101
          This is not a full application, just an extract.

          Presumably if "the application exits" on a click there is an error, and you get an error message somewhere.

          Your slot code in itself does nothing other than set two local variables. I do not know whether employeeList[0] is valid, nor whether in Staff_Summary_tableWidget.currentItem().text() there is indeed a current item set for currentItem() to return.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @JonB said in Single Click Event on Q:

          This is not a full application, just an extract.
          Presumably if "the application exits" on a click there is an error, and you get an error message somewhere.

          ?

          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