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. Using PyQt5 Objects inside QTabWidget and QScrollArea - QGIS Plugin

Using PyQt5 Objects inside QTabWidget and QScrollArea - QGIS Plugin

Scheduled Pinned Locked Moved Unsolved Qt for Python
4 Posts 3 Posters 632 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.
  • B Offline
    B Offline
    bemlun
    wrote on last edited by
    #1

    I'm using PyQt5 and QT Designer to create the user interface for my QGIS plugin. Now I'm learning to use QTabWidget and QScrollArea. What I don't understand is how to use the objects inside tabs or scroll areas. For example in my dialog there are two tabs, inside these there's a scroll area and finally the other objects like labels, lineEdits and buttons. You can see this in the image below. The problem is that if I try to use, as usual in my run method, simple functions like: self.dlg.label_2.setText() or self.dlg.lineEdit.text(), I receive this kind of error log: AttributeError: 'Dialog' object has no attribute 'label_2'. How to solve it?

    alt text

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

      Hi,

      Might be a silly question but are you sure the widget is properly initialised ?

      On an unrelated note, you should add layouts in your widget to make placement/size management automatic.

      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
      1
      • B Offline
        B Offline
        bemlun
        wrote on last edited by
        #3

        Hi, many thanks for your answer. To be honest, talking about layouts, I have not studied these aspects yet. About the first question, I'm not quite sure. I know that if I don't use tabWidget or scrollArea, I can work with labels, buttons and lineEdits without problems. I don't know if there's a particulare way to initialise tabWidget and scollArea, note that I'm using QtDesigner.

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

          Without seeing the code you are using I can't really comment about what is happening between the two versions of your widget.

          Depending on your fluency with developing widgets, you might also want to consider writing them by hand (it's more a question of taste).

          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