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. QTabWidget get the tab page's widgets
Forum Updated to NodeBB v4.3 + New Features

QTabWidget get the tab page's widgets

Scheduled Pinned Locked Moved Unsolved General and Desktop
pyqt5qtabwidgetqwidget
6 Posts 4 Posters 5.7k Views 2 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.
  • C Offline
    C Offline
    chronix
    wrote on last edited by
    #1

    So I'm using PyQt5 to develop an app.
    I'm able to create a new tab with a custom widget.
    This widget had 3 orther widgets in a custom layout, ie. a QTextEdit, a QLineEdit and a QPushButton.
    I can get the QWidget for the current tab, by tabWidget.currentWidget() bt I don't understand how to get to that QLineEdit or any of the other widgets for that matter.
    Can you tell me how to fix this problem?
    Thanks in advance :)

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      I have never tried PyQt5 so forgive me if not the same as c++.

      I assume you are not using UI files?
      so there is no UI to use ?

      You insert the widgets by new ?

      Maybe you can use findChildren function ?

      QList<QPushButton *> allPButtons = tabWidget.findChildren<QPushButton *>();

      C 1 Reply Last reply
      1
      • mrjjM mrjj

        Hi
        I have never tried PyQt5 so forgive me if not the same as c++.

        I assume you are not using UI files?
        so there is no UI to use ?

        You insert the widgets by new ?

        Maybe you can use findChildren function ?

        QList<QPushButton *> allPButtons = tabWidget.findChildren<QPushButton *>();

        C Offline
        C Offline
        chronix
        wrote on last edited by
        #3

        @mrjj
        Thank you replaying.
        yeah I'm using UI (UI files are not used directly, the are converted into python code, by a program, even C++ does with MOC, bt here we have to do it manually and import that python file) files bt to create a new tab i have to define a custom widget. Also no pointers in python, I understand your reply bt i don't know how to impilment it in python

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          Usually when someone tries to get the sub-widgets of a widget, there's a design issue in the making. Why do you need to get the QLineEdit for ?

          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
          • M Offline
            M Offline
            Masonsu
            wrote on last edited by
            #5

            ![alt text](image http://sip-communicator.org/wiki/pub/sip-communicator/screenshots/chat-window-dispmua.png)
            @SGaist Hi, SGaist, I am now have the same problem. I need to do a chat app, just like the image above. I create a tabwidget and the tabwidget have several chat pages. Every chat page is a class Chatlog, which contain a QTextEdit, a QLineEdit and a sendButton. My problem is when I receive a message from others, I know the name but I need to put the message into the right QTextEdit, Also , I need to mention that I define a QHash<QString, Chatlog*>, each name represent a chatpage. Now I don't have a good idea to achieve this, can you give me some advice?
            Thanks in advance

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Masonsu your QTextEdit is an implementation detail of your Chatlog widget. You should use e.g. a slot in Chatlog that will internally append the text to your QTextEdit. So if you change it for something else. You don't have to rewrite everything because of that.

              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

              • Login

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