[SOLVED] QTabWidget tabName and qplaintextedit::textChanged() signal problem
-
Hello everyone
void MainWindow::on_treeView_doubleClicked(const QModelIndex &index)
{if(index.isValid())
{
QModelIndex mapped=filter->mapToSource(index);
i=index;currentName=model->fileName(index);
}
}void MainWindow::text_Changed()
{
qDebug()<<currentName;
}and result = ""
does not print string
-
Hi,
What is text_Changed ? If it's a slot, how is it connected ?
-
connect(ui->plainTextEdit,SIGNAL(textChanged()),this,SLOT(addStar()));
-
hi
connect(ui->plainTextEdit,SIGNAL(textChanged()),this,SLOT(addStar()));
This connects to addStar() and not
text_Changed() ?
also , to make sure connect works, you can
QDebug() << " Text Change Signal:" << connect(ui->plainTextEdit,SIGNAL(textChanged()),this,SLOT(addStar()));
and see it returns true. -
result true . Only does not print qstring (currentName) in addStart() function
-
@takoo said:
qDebug()<<currentName;
well try with
qDebug()<<"hello";where is currentName defined? where do u set the value?
-
i have tried and result="hello" .
void MainWindow::on_treeView_doubleClicked(const QModelIndex &index)
{
if(index.isValid())
{
QModelIndex mapped=filter->mapToSource(index);
i=index;currentName=model->fileName(index);
sampleString=currentName;}
}
void MainWindow::text_Changed()
{
qDebug()<<sampleString; // currentName writes
ui->tabWidget_2->setTabText(ui->tabWÄ°dget_2->currentIndex(),ty+"*");//this not working}
-
hi
u are using
currentName=model->fileName(index);
and I sort expect it to be
currentName=model->fileName(mapped);
if u still have sort on.
//
ui->tabWidget_2->setTabText(ui->tabWÄ°dget_2->currentIndex(),ty+"*");//this not workingok. it looks strange. what are u trying to do ?
-
ok
and what part is not working?
Is currentindex valid?int sel=ui->tabWÄ°dget_2->currentIndex();
qDebug () << "sel is:" << sel;
ui->tabWidget_2->setTabText(sel,"test"); -
setTabText not working in addStar function. normally works(setTabText())
-
@takoo
Hi
It should do the same in any slot or function.
Are you sure its called
and the index and text you use are valid?
what did
qDebug () << "sel is:" << sel;
show you? -
sel = -1
-
@takoo
ok. ahh.
so index is not valid.
tabWÄ°dget_2->currentIndex() is -1 which means there is no
current/active tab.
try clicking tab before testing the text changed or change to
the first one.How many tabs did u add to it ?
-
I am add tab with code. So It's not certain tabcount. Index only not valid in textChanged(). Otherwise valid
-
ui->tabWidget_2->setTabText(0,"tabOne"); I tried it in addStar() function but not working
-
@takoo
sorry I am out of guesses.
if
ui->tabWidget_2->setTabText(0,"tabOne");
does not work, it have no idea then.Did u place break point on it and made sure its called?
You are 100% sure you are adding tabs to ui->tabWidget_2 and not
ui->tabWidget_1 or something else ? -
I am sure
-
mrjj Lifetime Qt Championreplied to takoo on 8 Feb 2016, 21:35 last edited by mrjj 2 Aug 2016, 21:44
@takoo
Well i'm out of guesses. sorry.
There is no reason that setTabText should not work.please see this small sample that change tabtext when u write in edit
https://www.dropbox.com/s/pm5uolmc7m0fo2w/mytabs.zip?dl=0
1/31