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. Signal and Slot with two different UI class in QT

Signal and Slot with two different UI class in QT

Scheduled Pinned Locked Moved Unsolved General and Desktop
qtablewidgetsignal & slotqt c++
2 Posts 2 Posters 935 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.
  • R Offline
    R Offline
    Rhutu
    wrote on last edited by
    #1

    I have a button in main ui window, where on click event Slot of different classes which contains QTablewidget's data.
    Thanks in advance.

    When I tried with from main class

    OtherClass *Obj=new OtherClass ();
    connect(ui.writeToFileButton,SIGNAL(clicked()),Obj,SLOT(WriteToFile()));
    As it calls WriteToFile() with new object,data got vanished from QTablewidget.

    I want to have modified data on signal ui.writeToFileButton,How can I get? Note: I have entered data through another widget in the table and able to connect signal and slot in the same class having QTableWidget ui.

    JonBJ 1 Reply Last reply
    0
    • R Rhutu

      I have a button in main ui window, where on click event Slot of different classes which contains QTablewidget's data.
      Thanks in advance.

      When I tried with from main class

      OtherClass *Obj=new OtherClass ();
      connect(ui.writeToFileButton,SIGNAL(clicked()),Obj,SLOT(WriteToFile()));
      As it calls WriteToFile() with new object,data got vanished from QTablewidget.

      I want to have modified data on signal ui.writeToFileButton,How can I get? Note: I have entered data through another widget in the table and able to connect signal and slot in the same class having QTableWidget ui.

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

      @Rhutu
      Nothing should "vanish". If you overwrite what is in QTableWidget with something not as you intended then obviously it will cease to show whatever it showed before.

      If you need to pass additional data from your main window to the slot, you can either do it via a C++ lambda for the slot, or put a slot which is in the main window instead of Obj,SLOT(WriteToFile()), and have that call Obj->WriteToFile(extra).

      Stop using old-style SIGNAL/SLOT() macros for signals/slots, use https://wiki.qt.io/New_Signal_Slot_Syntax, it's better and it will help you connect correct things.

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved