How to connect two Tabs in Applicatin?
Hello.
I have an Application with two Tabs:
- Tab1 (described in tab1.h file) has a QLineEdit widget.
- Tab2 (described in tab2.h file) has a QTableWidget widget.
They are added to Application in tabDialog.h file like this:
Code:
tabWidget->addTab(Tab1,"Tab1");
tabWidget->addTab(Tab2,"Tab2");
layout->addWidget(tabWidget);
setLayout(layout);
When user run my Application, text in QTableWidgetItem (in Tab2 Table) have to be changed when user press "Enter" in QLineEdit widget (in Tab1).
Could you please give me some idea how and where to connect SIGNAL(returnPressed()) from Tab1 with public slot from Tab2?
Re: How to connect two Tabs in Applicatin?
Quote:
They are added to Application in tabDialog.h (...)
Why are you creating your objects in a header ? And where exactly is the code called ? Is it inline constructor ?
About connection : connect tabs once after adding them to widget:
Code:
tabWidget->addTab(Tab1,"Tab1");
tabWidget->addTab(Tab2,"Tab2");
connect( Tab1, SIGNAL(returnPressed()), Tab2, SLOT(publicSlotFromTab2()) );
layout->addWidget(tabWidget);
setLayout(layout);
Re: How to connect two Tabs in Applicatin?
Quote:
Originally Posted by
stampede
Why are you creating your objects in a header ?
I create them in .cpp files. I have .h and .cpp files, as it have to be.
Quote:
Originally Posted by
stampede
And where exactly is the code called ?
In main.cpp like this:
Code:
int main(int argc,char *argv[])
{
tabDialog tabdialog;
return tabdialog.exec();
}
Quote:
Originally Posted by
stampede
connect( Tab1, SIGNAL(returnPressed()), Tab2, SLOT(publicSlotFromTab2()) );
This does not work. Tab2 in my Application does not change it's Table when user press "Enter" in QLineEdit in Tab1. Maybe I have to push Tab2 to "redraw" itself somehow? But how?
Re: How to connect two Tabs in Applicatin?
Quote:
This does not work
You mean that signal is not delivered to slot ? Try to see if connection call is ok:
Code:
bool status = connect(Tab1, ... );
qDebug() << "connection status: " << status;
Add some qDebugs in the slot itself as well and see if you can see them after pressing "return".