Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Spanish
  4. Cerrar cuadro ventana MdiArea
QtWS25 Last Chance

Cerrar cuadro ventana MdiArea

Scheduled Pinned Locked Moved Spanish
5 Posts 5 Posters 9.7k 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.
  • M Offline
    M Offline
    mrondon
    wrote on last edited by
    #1

    Saludos Chicos!

    Les escribo por que mi caso es el siguiente

    1. Tengo un QMdiArea que tiene un dialogo como ventana hija
    2. hago click en el boton cerrar del dialog y este no se cierra sino que desaparece todo el contenido del mismo

    como puedo cerrar este dialog?

    codigo que utilizo es

    @
    #include "dialog.h"
    #include "ui_dialog.h"

    Dialog::Dialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog)
    {
    ui->setupUi(this);

    connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(closeWindow()));
    

    }

    Dialog::~Dialog()
    {
    delete ui;
    }

    void Dialog::closeWindow()
    {
    this->close();
    }
    @

    1 Reply Last reply
    0
    • I Offline
      I Offline
      Iktwo
      wrote on last edited by
      #2

      Hola, al hacer this->close(); el método debería ejecutarse sobre tu Dialog, decis que al darle click al botón te borra el contenido, pero no cierra el dialogo? He utilizado dialogos y nunca he tenido que programar el botón de cerrar, podrías explicarme un poco más tu problema?

      Te recomiendo que uses nombres representativos para tus componentes, podrías renombrar ese pushButton a algo como btnCerrar, bueno espero poder ayudarte, saludos!

      1 Reply Last reply
      0
      • X Offline
        X Offline
        xlarsx
        wrote on last edited by
        #3

        Tengo el siguiente código y el funcionamiento es el esperado, podrías comentar en que difiere en general:

        dialog.h
        @
        #ifndef DIALOG_H
        #define DIALOG_H

        #include <QDialog>

        namespace Ui {
        class Dialog;
        }

        class Dialog : public QDialog
        {
        Q_OBJECT

        public:
        explicit Dialog(QWidget *parent = 0);
        ~Dialog();

        public slots:
        void closeWindow();

        private:
        Ui::Dialog *ui;
        };

        #endif // DIALOG_H
        @

        dialog.cpp
        @
        #include "dialog.h"
        #include "ui_dialog.h"

        Dialog::Dialog(QWidget *parent) :
        QDialog(parent),
        ui(new Ui::Dialog)
        {
        ui->setupUi(this);

        connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(closeWindow()));
        

        }

        Dialog::~Dialog()
        {
        delete ui;
        }

        void Dialog::closeWindow()
        {
        this->close();
        }
        @

        Dialog.ui

        @
        <?xml version="1.0" encoding="UTF-8"?>
        <ui version="4.0">
        <class>Dialog</class>
        <widget class="QDialog" name="Dialog">
        <property name="geometry">
        <rect>
        <x>0</x>
        <y>0</y>
        <width>400</width>
        <height>300</height>
        </rect>
        </property>
        <property name="windowTitle">
        <string>Dialog</string>
        </property>
        <widget class="QPushButton" name="pushButton">
        <property name="geometry">
        <rect>
        <x>300</x>
        <y>250</y>
        <width>75</width>
        <height>23</height>
        </rect>
        </property>
        <property name="text">
        <string>PushButton</string>
        </property>
        </widget>
        </widget>
        <layoutdefault spacing="6" margin="11"/>
        <resources/>
        <connections/>
        </ui>
        @

        Saludos

        1 Reply Last reply
        0
        • L Offline
          L Offline
          lili
          wrote on last edited by
          #4

          Hola mrondon me esta pasando lo mismo, pudiste solucionarlo.
          pq con this->close(); solo me oculta el contenido de la ventana pero no la cierra :(

          1 Reply Last reply
          0
          • T Offline
            T Offline
            topocc
            wrote on last edited by
            #5

            has probado con close.

            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