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. Can we allow only one widget to layout?

Can we allow only one widget to layout?

Scheduled Pinned Locked Moved Unsolved Qt for Python
7 Posts 2 Posters 1.1k 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.
  • A Offline
    A Offline
    aadil50
    wrote on last edited by
    #1

    I have a situation where I want to make a graph (matplotlib)..When I push button, it takes data from qlineedits and make a graph in UI which contain qwidget->scroll->vboxlayout.. When I press button it makes graph.. but when I edit data instead of updating my graph it adds another graph.. So I want one edited graph.. how can i do this?

    jsulmJ 1 Reply Last reply
    0
    • A aadil50

      I have a situation where I want to make a graph (matplotlib)..When I push button, it takes data from qlineedits and make a graph in UI which contain qwidget->scroll->vboxlayout.. When I press button it makes graph.. but when I edit data instead of updating my graph it adds another graph.. So I want one edited graph.. how can i do this?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @aadil50 said in Can we allow only one widget to layout?:

      how can i do this?

      Don't add second one, right?
      So, fix your code and only add graph if there is no graph yet.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • A Offline
        A Offline
        aadil50
        wrote on last edited by
        #3

        Putting in mind my heirarchy of widgets can you please tell me how can i put such condition to add only one graph if it is present?

        jsulmJ 1 Reply Last reply
        0
        • A aadil50

          Putting in mind my heirarchy of widgets can you please tell me how can i put such condition to add only one graph if it is present?

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by jsulm
          #4

          @aadil50 Isn't it simple?

          if (!ui->graphWidget) {
              // Create the graph widget: ui->graphWidget = new ...
              // Add the graph widget to the layout
          }
          

          ui->graphWidget is just a place holder, adjust it to your code.
          I also assume that you initialize ui->graphWidget as nullptr.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • A Offline
            A Offline
            aadil50
            wrote on last edited by
            #5

            Can you please translate it to Python Pyqt5?

            jsulmJ 1 Reply Last reply
            0
            • A aadil50

              Can you please translate it to Python Pyqt5?

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @aadil50 Come on, it's also not that hard...

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              A 1 Reply Last reply
              1
              • jsulmJ jsulm

                @aadil50 Come on, it's also not that hard...

                A Offline
                A Offline
                aadil50
                wrote on last edited by
                #7

                @jsulm Thanks.. I am trying..

                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