You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Friday, July 24th 2009, 11:40am

How to hide subwindow in mdiarea.

Hello.

I have main class window. I create MdiArea and subwindow.

In main class constructor i try to use mainwindow->subwindow->hide() and mainwindow->subwindow->setVisible(false) but this is not working.

I whant hide all subwindow at the start of the program, and then with buttons unhide / hide subwindows.

Do You have some idea ?

Greetings.

thec0der

Beginner

  • "thec0der" is male

Posts: 39

Location: Bulgaria

  • Send private message

2

Friday, July 24th 2009, 12:06pm

Try

Source code

1
mdiArea->setVisible(true);

It works for me.

3

Friday, July 24th 2009, 12:11pm

Try

Source code

1
mdiArea->setVisible(true);

It works for me.


Yes, it works, but this method hide whole MdiArea - I whant to hide some of subwindows in this area.

Excaple I have MdiArea wiht three subwinows sub_1, sub_2, sub_3.

When I start the application I whant to have all subiwnodows hide ( but not MdiArea ). When I click on pushbutton ex. push_1 then I whant unhide sub_1, push_2 unhide sub_2 ...

That strangely, because when I use mainwindow->subwindow->hide(), then all widgets ( puttnons, lineedit ...) on subwindow disappear but not subwindow.

This post has been edited 1 times, last edit by "herk" (Jul 24th 2009, 12:25pm)


thec0der

Beginner

  • "thec0der" is male

Posts: 39

Location: Bulgaria

  • Send private message

4

Friday, July 24th 2009, 12:44pm

Hm.. very very strange...
even

Source code

1
ui->mdiArea->removeSubWindow(.....);
does not work correctly.

5

Friday, July 24th 2009, 12:52pm

Hm.. very very strange...
even

Source code

1
ui->mdiArea->removeSubWindow(.....);
does not work correctly.


Yes, this is not working too - remove all widgets from subwindow but not subwindow.

In Attachments i send whole project. If You can please have a look in to mainwindow1.cpp file.

I thint I do something wrong with creating MidiArea, thats look like subwindow was a tabwidget ...
herk has attached the following file:
  • QTGui.zip (13.22 kB - 44 times downloaded - latest: Yesterday, 11:29pm)

thec0der

Beginner

  • "thec0der" is male

Posts: 39

Location: Bulgaria

  • Send private message

6

Friday, July 24th 2009, 1:39pm

Finally - some progress
Hide all subWindows of mdi

Source code

1
2
3
4
5
6
7
	QList<QMdiSubWindow *> wnd = ui->mdiArea->subWindowList();

	QList<QMdiSubWindow *>::iterator i;

	for (i=wnd.begin();i!= wnd.end();++i) {
    	(*i)->hide();
	}

7

Friday, July 24th 2009, 1:53pm

Thank You for Your help :-) it's working.

8

Saturday, July 25th 2009, 12:29pm

Another problem :-)

Can You help me to solve this problem : How to "catch" close signal from subwindow?

When the user close window I don't whant to destroy this subwindow but hide. I whant to have sub windows to multiple use, byt when the user close subwindow every widghet on him was destroy.

And one more question. Sorry for that, but I don't find any slution.

I have tabwidget in separate ui file, and my question is : How to show this tabwidget on mainwindow ?

This post has been edited 1 times, last edit by "herk" (Jul 25th 2009, 12:43pm)


9

Saturday, July 25th 2009, 1:12pm

1)
reimplement
void QWidget::closeEvent( QCloseEvent * ev )
or better
clear flag deleteOnClose

10

Saturday, July 25th 2009, 4:42pm

1)
reimplement
void QWidget::closeEvent( QCloseEvent * ev )
or better
clear flag deleteOnClose


It's work :) setAttribute(Qt::WA_DeleteOnClose, false);

Some information to second issue.

I have mainwindow class, and in separated ui file I have QTabWidget.

Mainwindow class :

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
class MainWindow1 : public QMainWindow
{
    Q_OBJECT

public:
     MainWindow1(QWidget *parent = 0);
    ~MainWindow1();

    // THIS IS A POINTER TO CLASS WITH QTabWidget
    DanePrzychodni * dp_table;
	
public slots:
    void w1_action_dane_przychodni();

private:
    Ui::MainWindow1  * ok1;
};

MainWindow1::MainWindow1(QWidget *parent)
    : QMainWindow(parent),ok1(new Ui::MainWindow1)
{
    ok1->setupUi(this);

    // CREATE OBJECT
    dp_table = new DanePrzychodni;
}

MainWindow1::~MainWindow1()
{
    if(ok1)
    {
        delete ok1;
        ok1 = 0;
    }

}

void MainWindow1::w1_action_dane_przychodni()
{
    dp_table->show();
    // SHOW TAB WIDGET
}


QTabWidget

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class DanePrzychodni : public QTabWidget
{
    Q_OBJECT

public:
     DanePrzychodni(QWidget *parent = 0);
    ~DanePrzychodni();


private:
    Ui::DanePrzychodni  * DP;
};

DanePrzychodni::DanePrzychodni(QWidget *parent)
    : QTabWidget(parent),DP(new Ui::DanePrzychodni)
{
    DP->setupUi(this);
}

DanePrzychodni::~DanePrzychodni()
{
    if(DP)
    {
        delete DP;
        DP = 0;
    }

}


The problem is, that TabWidet is opened like a new window, but i whant somethig like insert this widget in mainwindow form.


I need to have this widget in separated file, because appliaction will be have many of different tabwidget.

Do You have some idea ?

Greetings.

11

Sunday, July 26th 2009, 9:33am

in designer
open mainwindow1.ui
insert a QTabWidget
promote this QTabWidget to DanePrzychodni (right click --> Promote to ...)