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. QWidget add to QScrollArea
Forum Updated to NodeBB v4.3 + New Features

QWidget add to QScrollArea

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 526 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.
  • jondoeJ Offline
    jondoeJ Offline
    jondoe
    wrote on last edited by
    #1

    Hello,
    I have QScrollArea and QWidget ( in label and pushbutton ).
    When I clicking to red push button i want add yellow widget to QScrollArea with label and pushbuttons. How can I do this ?

    http://prntscr.com/n5eycy

    JonBJ 1 Reply Last reply
    0
    • jondoeJ jondoe

      Hello,
      I have QScrollArea and QWidget ( in label and pushbutton ).
      When I clicking to red push button i want add yellow widget to QScrollArea with label and pushbuttons. How can I do this ?

      http://prntscr.com/n5eycy

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

      @jondoe
      From your screenshot: do you mean you want to add a new yellow widget (with *image + pushbutton) just like the one you have on the right, or do you mean you want to move the existing widget (+ content) at the right so that it is now inside the QScrollArea?

      Either way you will be using https://doc.qt.io/Qt-5/qscrollarea.html#setWidget to set the QScrollArea's widget to your yellow widget (maybe plus layout), it's only a question of whether you create a copy of your yellow one or make it your existing one.

      jondoeJ 1 Reply Last reply
      0
      • JonBJ JonB

        @jondoe
        From your screenshot: do you mean you want to add a new yellow widget (with *image + pushbutton) just like the one you have on the right, or do you mean you want to move the existing widget (+ content) at the right so that it is now inside the QScrollArea?

        Either way you will be using https://doc.qt.io/Qt-5/qscrollarea.html#setWidget to set the QScrollArea's widget to your yellow widget (maybe plus layout), it's only a question of whether you create a copy of your yellow one or make it your existing one.

        jondoeJ Offline
        jondoeJ Offline
        jondoe
        wrote on last edited by
        #3

        @JonB said in QWidget add to QScrollArea:

        want to add a new yellow widget (with *image + pushbutton) just like the one you have on the right

        I want to add a new yellow widget (with *image + pushbutton) just like the one I have on the right.

        JonBJ 1 Reply Last reply
        0
        • jondoeJ jondoe

          @JonB said in QWidget add to QScrollArea:

          want to add a new yellow widget (with *image + pushbutton) just like the one you have on the right

          I want to add a new yellow widget (with *image + pushbutton) just like the one I have on the right.

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

          @jondoe
          So you will write "copy" code to create the new widgets from the yellow widget you have downward into its content. There is (deliberately) no QWidget copy constructor, so you will create new widgets via new QWidget/QLabel/QOushbutton and it is your job to copy whatever attributes are currently on the old widgets into the new widgets, e.g. color, size etc. (e.g. see https://www.qtcentre.org/threads/26546-Deep-copy-of-widget-hierarchy for confirmation that this is the way to go) If you don't want to have to know what the children are to start with, you can use one of the QObject::findChildren overloads inherited by QWidget to discover all children programmatically.

          1 Reply Last reply
          1

          • Login

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