Important: Please read the Qt Code of Conduct -

Signal and Slot with two different UI class in QT

  • 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 ();
    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.

  • @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, it's better and it will help you connect correct things.