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. Delete a DockWidget:

Delete a DockWidget:

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 939 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    I wrote:

    QSharedPointer < QDockWidget > dock = QSharedPointer < QDockWidget > ( new QDockWidget(this));
            
           
            dock->setMinimumWidth(500);
            dock->setMaximumWidth(500);
            dock->setMinimumHeight(500);
            dock->setMaximumHeight(500);
    
            //creo un grafico che contiene i dati di graph4
             
            
            QCustomPlot a = new QCustomPlot(dock);
    dock->setAttribute(Qt::WA_DeleteOnClose);
    

    When I pass dock to QCustomPlot a I have an errore...I would like delete the dock when I close it and delete all the elements inside when I close the dock

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

      Hi,

      What error do you have ?

      Why are you setting the dock widget as parent rather than set the chart on the dock widget ?

      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
      • SGaistS SGaist

        Hi,

        What error do you have ?

        Why are you setting the dock widget as parent rather than set the chart on the dock widget ?

        ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        @SGaist I have an error in build because dock is a parent of QCustomPlot a..dock must be a parent of a because when I delete dock also a must be deleted

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

          The right way to proceed is to use QDockWidget::setWidget.

          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
          • SGaistS SGaist

            The right way to proceed is to use QDockWidget::setWidget.

            ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            @SGaist but if I write in this way "a" becomes a child of dock?anyway QCustomPlot wants a parent, without parenthys I have an errore in build

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

              Becoming a child like that or being set are two different concept even if the second usually means that the widget becomes a child there are more to it.

              And no, QCustomPlot doesn't want a parent but you can pass it one if you want. The parent parameter has a default value as most of QWidget based classes.

              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

              • Login

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