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. [SOLVED] QTabWidget tabName and qplaintextedit::textChanged() signal problem
QtWS25 Last Chance

[SOLVED] QTabWidget tabName and qplaintextedit::textChanged() signal problem

Scheduled Pinned Locked Moved Unsolved General and Desktop
qplaintexteditqstringqtabwidget
31 Posts 3 Posters 9.7k 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.
  • T Offline
    T Offline
    takoo
    wrote on 6 Feb 2016, 17:08 last edited by takoo 2 Nov 2016, 20:24
    #1

    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

    I just write code ------- (-_-) ----------

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 6 Feb 2016, 21:15 last edited by
      #2

      Hi,

      What is text_Changed ? If it's a slot, how is it connected ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • T Offline
        T Offline
        takoo
        wrote on 7 Feb 2016, 13:19 last edited by
        #3

        connect(ui->plainTextEdit,SIGNAL(textChanged()),this,SLOT(addStar()));

        I just write code ------- (-_-) ----------

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 7 Feb 2016, 13:46 last edited by
          #4

          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.

          1 Reply Last reply
          0
          • T Offline
            T Offline
            takoo
            wrote on 7 Feb 2016, 15:40 last edited by
            #5

            result true . Only does not print qstring (currentName) in addStart() function

            I just write code ------- (-_-) ----------

            M 1 Reply Last reply 7 Feb 2016, 16:29
            0
            • T takoo
              7 Feb 2016, 15:40

              result true . Only does not print qstring (currentName) in addStart() function

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 7 Feb 2016, 16:29 last edited by
              #6

              @takoo said:

              qDebug()<<currentName;

              well try with
              qDebug()<<"hello";

              where is currentName defined? where do u set the value?

              1 Reply Last reply
              0
              • T Offline
                T Offline
                takoo
                wrote on 7 Feb 2016, 16:50 last edited by
                #7

                i have tried and result="hello" .

                void MainWindow::on_treeView_doubleClicked(const QModelIndex &index)

                {

                if(index.isValid())
                {
                Q

                ModelIndex 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

                }

                I just write code ------- (-_-) ----------

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 7 Feb 2016, 17:07 last edited by
                  #8

                  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 working

                  ok. it looks strange. what are u trying to do ?

                  1 Reply Last reply
                  0
                  • T Offline
                    T Offline
                    takoo
                    wrote on 7 Feb 2016, 18:06 last edited by
                    #9

                    @mrjj if text change of my plainTextEdit when I want to change tab text of qtabwidget

                    I just write code ------- (-_-) ----------

                    M 1 Reply Last reply 7 Feb 2016, 18:37
                    0
                    • T takoo
                      7 Feb 2016, 18:06

                      @mrjj if text change of my plainTextEdit when I want to change tab text of qtabwidget

                      M Offline
                      M Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on 7 Feb 2016, 18:37 last edited by
                      #10

                      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");

                      1 Reply Last reply
                      0
                      • T Offline
                        T Offline
                        takoo
                        wrote on 7 Feb 2016, 18:50 last edited by
                        #11

                        setTabText not working in addStar function. normally works(setTabText())

                        I just write code ------- (-_-) ----------

                        M 1 Reply Last reply 7 Feb 2016, 19:08
                        0
                        • T takoo
                          7 Feb 2016, 18:50

                          setTabText not working in addStar function. normally works(setTabText())

                          M Offline
                          M Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on 7 Feb 2016, 19:08 last edited by
                          #12

                          @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?

                          1 Reply Last reply
                          0
                          • T Offline
                            T Offline
                            takoo
                            wrote on 7 Feb 2016, 19:16 last edited by
                            #13

                            sel = -1

                            I just write code ------- (-_-) ----------

                            M 1 Reply Last reply 7 Feb 2016, 19:29
                            0
                            • T takoo
                              7 Feb 2016, 19:16

                              sel = -1

                              M Offline
                              M Offline
                              mrjj
                              Lifetime Qt Champion
                              wrote on 7 Feb 2016, 19:29 last edited by
                              #14

                              @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 ?

                              1 Reply Last reply
                              0
                              • T Offline
                                T Offline
                                takoo
                                wrote on 7 Feb 2016, 19:50 last edited by
                                #15

                                I am add tab with code. So It's not certain tabcount. Index only not valid in textChanged(). Otherwise valid

                                I just write code ------- (-_-) ----------

                                1 Reply Last reply
                                0
                                • T Offline
                                  T Offline
                                  takoo
                                  wrote on 7 Feb 2016, 19:55 last edited by
                                  #16

                                  ui->tabWidget_2->setTabText(0,"tabOne"); I tried it in addStar() function but not working

                                  I just write code ------- (-_-) ----------

                                  M 1 Reply Last reply 7 Feb 2016, 20:13
                                  0
                                  • T takoo
                                    7 Feb 2016, 19:55

                                    ui->tabWidget_2->setTabText(0,"tabOne"); I tried it in addStar() function but not working

                                    M Offline
                                    M Offline
                                    mrjj
                                    Lifetime Qt Champion
                                    wrote on 7 Feb 2016, 20:13 last edited by
                                    #17

                                    @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 ?

                                    1 Reply Last reply
                                    0
                                    • T Offline
                                      T Offline
                                      takoo
                                      wrote on 8 Feb 2016, 17:50 last edited by
                                      #18

                                      I am sure

                                      I just write code ------- (-_-) ----------

                                      M 1 Reply Last reply 8 Feb 2016, 21:35
                                      0
                                      • T takoo
                                        8 Feb 2016, 17:50

                                        I am sure

                                        M Offline
                                        M Offline
                                        mrjj
                                        Lifetime Qt Champion
                                        wrote on 8 Feb 2016, 21:35 last edited by mrjj 2 Aug 2016, 21:44
                                        #19

                                        @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 Reply Last reply
                                        1
                                        • T Offline
                                          T Offline
                                          takoo
                                          wrote on 9 Feb 2016, 18:14 last edited by
                                          #20

                                          @mrjj I've identified problem. not see anything about qTabWidget in function textChanged()

                                          I just write code ------- (-_-) ----------

                                          M 1 Reply Last reply 10 Feb 2016, 06:57
                                          0

                                          7/31

                                          7 Feb 2016, 16:50

                                          topic:navigator.unread, 24
                                          • Login

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