Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

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

    General and Desktop
    8
    14
    12986
    Loading More Posts
    • 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.
    • R
      Ruzik last edited by

      How can i get pointer on the widget of current tab in QTabWidget?
      Advance many thanks fro help!

      1 Reply Last reply Reply Quote 0
      • L
        lgeyer last edited by

        "QTabWidget::currentWidget()":http://doc.qt.nokia.com/latest/qtabwidget.html#currentWidget

        1 Reply Last reply Reply Quote 0
        • A
          aureshinite last edited by

          "Wow do you read the doc??..":http://doc.qt.nokia.com/4.7-snapshot/qtabwidget.html#currentWidget

          1 Reply Last reply Reply Quote 0
          • R
            Ruzik last edited by

            I read it before i asked, but on the this code
            @ tabWidget->addTab(new QPlainTextEdit, "New tab");
            QPlainTextEdit * p = qobject_cast<QPlainTextEdit *>(tabWidget->currentWidget());
            p->setPlainText("dsg");@
            Compiler get me a error, and thats why i asked you about it

            1 Reply Last reply Reply Quote 0
            • G
              giesbert last edited by

              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 Reply Quote 0
              • R
                Ruzik last edited by

                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 Reply Quote 0
                • R
                  Ruzik last edited by

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

                  1 Reply Last reply Reply Quote 0
                  • G
                    giesbert last edited by

                    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 Reply Quote 0
                    • L
                      ludde last edited by

                      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 Reply Quote 0
                      • R
                        Ruzik last edited by

                        Many thanks for your help - i find error!

                        1 Reply Last reply Reply Quote 0
                        • M
                          mlong last edited by

                          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 Reply Quote 0
                          • R
                            Ruzik last edited by

                            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 Reply Quote 0
                            • Q
                              Qlearner last edited by

                              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 Reply Quote 0
                              • V
                                vittalonline last edited by

                                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 Reply Quote 0
                                • First post
                                  Last post