Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Accessing the text in a TextEdit that is allocated to a QMdiSubWindow

Accessing the text in a TextEdit that is allocated to a QMdiSubWindow

Scheduled Pinned Locked Moved Solved Qt for Python
qt for pythonpython
3 Posts 2 Posters 671 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.
  • P Offline
    P Offline
    Pixelhead120
    wrote on last edited by
    #1

    Hi, very new to python and PyQT6. So jumping in the deep end I have been working on an MDI text Editor and have met a number of issues but the main one I cannot get past as it appears nobody covers it.
    pic1.png
    It is how do you access the QTextEdit widget to work on text within the window as a normal text editor is supposed to??
    I understand the mdi calls to move through the windows but as you can see on the pic2 the only reference I can get is the memory address as once I setWidget() the QTextEdit abilities are lost to me.!
    pic2.png
    I hope that makes sense, I can type in text into the window but say I wanted to to highlight text and hit Bold on the toolbar I do not know how to reference that text. Any help would be appreciated, thanks in advance.

    JonBJ 1 Reply Last reply
    0
    • P Pixelhead120

      Hi, very new to python and PyQT6. So jumping in the deep end I have been working on an MDI text Editor and have met a number of issues but the main one I cannot get past as it appears nobody covers it.
      pic1.png
      It is how do you access the QTextEdit widget to work on text within the window as a normal text editor is supposed to??
      I understand the mdi calls to move through the windows but as you can see on the pic2 the only reference I can get is the memory address as once I setWidget() the QTextEdit abilities are lost to me.!
      pic2.png
      I hope that makes sense, I can type in text into the window but say I wanted to to highlight text and hit Bold on the toolbar I do not know how to reference that text. Any help would be appreciated, thanks in advance.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @Pixelhead120
      Hello and welcome.

      Next time please copy & paste code as text (use Code toolbar button here </>), so that responders can access your code.

      filenew.setWidget(QTextEdit)
      

      There are a several ways of accessing this widget after you create it, including:

      • self.mdi.currentSubwindow().widget() / w.widget()
      • self.textEdit = QTextEdit() before filenew.setWidget(self.textEdit) instead of filenew.setWidget(QTextEdit)

      You will want to think about where and what self to keep variables etc. for MDI subwindows under. It quickly gets messy keeping everything in MainWindow, you may want classes and their own member variables for MDI subwindows.

      There is absolutely nothing special about a QTextEdit happening to be on an MDI subwindow.

      P 1 Reply Last reply
      1
      • JonBJ JonB

        @Pixelhead120
        Hello and welcome.

        Next time please copy & paste code as text (use Code toolbar button here </>), so that responders can access your code.

        filenew.setWidget(QTextEdit)
        

        There are a several ways of accessing this widget after you create it, including:

        • self.mdi.currentSubwindow().widget() / w.widget()
        • self.textEdit = QTextEdit() before filenew.setWidget(self.textEdit) instead of filenew.setWidget(QTextEdit)

        You will want to think about where and what self to keep variables etc. for MDI subwindows under. It quickly gets messy keeping everything in MainWindow, you may want classes and their own member variables for MDI subwindows.

        There is absolutely nothing special about a QTextEdit happening to be on an MDI subwindow.

        P Offline
        P Offline
        Pixelhead120
        wrote on last edited by
        #3

        @JonB Thank you for your advice and will have a look at what you've given me.

        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