PDA

View Full Version : Add tab (QtabWidget defined in UI file)



sang
24th August 2010, 10:44
Hei,
I have a problem, designing my GUI in QtDesigner and adding QTabWidget, because it add tab's in there (UI file no tab's).

Code:


connect( pushButton, SIGNAL(clicked()), this, SLOT(addChatTab("Name")) );


void MyClass::addChatTab( QString name )
{
QWidget *newTab = new QWidget( tabWidget );
tabWidget->addTab( newTab, ( name ) );
}

And if I clicked this button no tab's appering.

tbscope
24th August 2010, 10:51
The following is not possible:

connect( pushButton, SIGNAL(clicked()), this, SLOT(addChatTab("Name")) );
A slot can have maximum the same amount of parameters as the signal.

sang
24th August 2010, 11:19
Ok now works! If i remove QString param!

I can't either one param in slot?

sang
24th August 2010, 15:36
void MyClass::addChatTab()
{
QWidget *newTab = new QWidget( tabWidget );
QLabel *fileNameLabel = new QLabel(tr("File Name:"));
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(fileNameLabel);
setLayout(mainLayout);
tabWidget->addTab( newTab, ( "New tab" ) );
}

How to add buttons/layout or something tabWidget, now it not works!