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. How can i get pointer on the widget of current tab in QTabWidget?
Forum Updated to NodeBB v4.3 + New Features

How can i get pointer on the widget of current tab in QTabWidget?

Scheduled Pinned Locked Moved General and Desktop
14 Posts 8 Posters 13.8k Views 1 Watching
  • 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.
  • G Offline
    G Offline
    giesbert
    wrote on last edited by
    #5

    which error?

    Nokia Certified Qt Specialist.
    Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

    1 Reply Last reply
    0
    • R Offline
      R Offline
      Ruzik
      wrote on last edited by
      #6

      If i change code:
      @ tabWidget->addTab(new QPlainTextEdit, "New tab");
      QPlainTextEdit * p = qobject_cast<QPlainTextEdit *>(tabWidget->currentWidget());
      if (p)
      p->setPlainText("dsg");@
      It is work right, but conversion does not occur

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Ruzik
        wrote on last edited by
        #7

        [quote author="Gerolf" date="1308252787"]which error?[/quote]
        Access violation when reading

        1 Reply Last reply
        0
        • G Offline
          G Offline
          giesbert
          wrote on last edited by
          #8

          is the new tab the current one? are you sure?

          Nokia Certified Qt Specialist.
          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

          1 Reply Last reply
          0
          • L Offline
            L Offline
            ludde
            wrote on last edited by
            #9

            A bit hard to see what's wrong from just those four lines of code.
            I assume qssTextEdit is a QPlainTextEdit subclass?
            And that you haven't added any other tabs?
            You could always check what tabWidget->currentWidget() actually returns, using a debugger or some form of debug output, e.g. by printing what tabWidget->currentWidget()->metaObject()->className() returns.

            1 Reply Last reply
            0
            • R Offline
              R Offline
              Ruzik
              wrote on last edited by
              #10

              Many thanks for your help - i find error!

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mlong
                wrote on last edited by
                #11

                What was it? (For those of us who are keeping score...)

                Software Engineer
                My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  Ruzik
                  wrote on last edited by
                  #12

                  I'm in the designer created a table and a default is already located there QPlainTextEdit and when I addressed him, it is transformed into kvidget, not QPlainTextEdit

                  1 Reply Last reply
                  0
                  • Q Offline
                    Q Offline
                    Qlearner
                    wrote on last edited by
                    #13

                    To read the text associated with a tab's QTextEdit widget ( tab at index x) , I did this
                    @ tabWidget->addTab(new QTextEdit ,"New tab");
                    QTextEdit* t= qobject_cast<QTextEdit*>(tabWidget->widget(x));
                    qDebug() << t->toPlainText();
                    @

                    Just in case someone still needed it.

                    1 Reply Last reply
                    0
                    • V Offline
                      V Offline
                      vittalonline
                      wrote on last edited by
                      #14

                      Hi.. Ruzik

                      once try this code..

                      QTabWidget *wd;
                      tabWidget->addTab(new QTextEdit ,"New tab");

                      QList<QTextEdit * > widgets = wd->findChildren<QTextEdit* >();
                      .....

                      widgets.at(2) or widgets.at(index)

                      1 Reply Last reply
                      0

                      • Login

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