maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   Please help about stacked windows (https://talk.maemo.org/showthread.php?t=58934)

mmichielin 2010-07-22 08:02

Please help about stacked windows
 
Hi,

I'm trying to build my first complete multi-windows qt n900 application (I've already built a simple application and I was able to run it on my n900).

I've installed latest version of nokia qt creator (LGPL install) downloaded from here on ubuntu lucid-64.

Now I'm stuck with stacked windows: I really don't understand how to do it.
I tried to code the example presented in qt creator help but I was not able to run it (WA_Maemo5StakedWindows is not a member of qt) and any other test was a failure.

I have the start window with many pushbutton and I'd like each button to open a different child (stacked) window.

1) First of all, I don't know how to draw different windows (different .ui files) inside the same project
2) Second I don't know how to stack one window on another

I really don't understand how to do it INSIDE QT Creator (I mean without coding everything from scratch).

Should I try a different SDK?

Can please someone help me?
Any general indication as far as complete code example are really appreciated.

Thanks in advance
Michele

naabi 2010-07-22 09:17

Re: Please help about stacked windows
 
1 Attachment(s)
For adding new UI files you just need to go to Add New... and select Qt/Qt Designer Form Class (see pic). It adds a new .ui file and skeletons for header and source.

What comes to stacked windows I think you need to verify that also each widget inside the new window has the Qt::WA_Maemo5StackedWindow property set. Otherwise the window will open as a normal window.

mmichielin 2010-07-22 10:00

Re: Please help about stacked windows
 
Thanks a lot.

But I'm still having some problem.

1) Now I have two windows - one called Finestra01 and the other Finestra02 ("finestra" in italian means window...)

2) I've manually included Finestra02 header in Finestra01.cpp to make Finestra01 aware that Finestra02 exists:
Code:

#include "finestra02.h"
#include "ui_finestra02.h"

3) I've added few lines of code in Finestra01.cpp to open FInestra02 when I click the pushbutton in Finestra 01:
Code:

void Finestra01::on_pushButton_clicked()
{
    Finestra02 f2;

    f2.show();
}

The program compiles but when a push Finestra01 pushbutton nothing happens.

4) If I add this line to Finestra01::on_pushButton_clicked() I obtain a compiler error:
Code:

void Finestra01::on_pushButton_clicked()
{
    Finestra02 f2;

    f2.setAttribute(Qt::WA_Maemo5StackedWindow); // THIS LINE RETURNS A COMPILER ERROR (WA_Maemo5StackedWindow is not a member of Qt)
    f2.show();
}

There is something wrong for sure.

Can you tell me what's wrong?

Thanks again

hqh 2010-07-22 10:06

Re: Please help about stacked windows
 
Quote:

Originally Posted by mmichielin (Post 760531)
Can you tell me what's wrong?

You'll have to add
Code:

#ifdef Q_WS_MAEMO_5
#include <QtMaemo5>
#endif

to your includes, and also

Code:

maemo5 {
    QT += maemo5
}

to your project file.

It won't do anything on the "simulator", which in it's current state is pretty useless IMO, but should work when compiled for the real device.

In addition, you have to set the attribute on ALL of your windows, and thanks to a bug or a feature in Qt, also reset the window flag after setting it:
Code:

#ifdef Q_WS_MAEMO_5
        window.setAttribute(Qt::WA_Maemo5StackedWindow);
        window.setWindowFlags(Qt::Window);
#endif


mmichielin 2010-07-22 10:20

Re: Please help about stacked windows
 
Thanks.

I'm unsure on where to add the last block of code, so I've added in the costructor (if it is called so...):

Code:

Finestra01::Finestra01(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::Finestra01)
{
    ui->setupUi(this);
#ifdef Q_WS_MAEMO_5
    window->setAttribute(Qt::WA_Maemo5StackedWindow);
    window->setWindowFlags(Qt::Window);
#endif
}

Do you think it's right?

However nothing happens in the simulator (only a glitch...), you mean that if I run the application on my N900 I should see something working better?

Thanks again
Michele

hqh 2010-07-22 10:30

Re: Please help about stacked windows
 
Quote:

Originally Posted by mmichielin (Post 760562)
Do you think it's right?

However nothing happens in the simulator (only a glitch...), you mean that if I run the application on my N900 I should see something working better?

The constructor is a good place to set those, but you'll have to change it to "this->" instead of "window->".

Yes, you'll have to run it on the N900 to see it working.

mmichielin 2010-07-22 12:19

Re: Please help about stacked windows
 
Quote:

Originally Posted by hqh (Post 760580)
The constructor is a good place to set those, but you'll have to change it to "this->" instead of "window->".

Yes, you'll have to run it on the N900 to see it working.

OK, I'll try.

Thank you very much.

However, I ask myself why all this small pieces of code are not included by default in the templates by QT Creator when I create a Maemo 5 application...

I'll let you know how my tests evolve.

Venemo 2010-07-22 14:34

Re: Please help about stacked windows
 
A very good link and explanation about stacked windows:

http://doc.qt.nokia.com/qt-maemo-4.6...edwindows.html

naabi 2010-07-22 15:28

Re: Please help about stacked windows
 
Quote:

Originally Posted by mmichielin (Post 760683)
However, I ask myself why all this small pieces of code are not included by default in the templates by QT Creator when I create a Maemo 5 application...

Qt enables code that can be compiled for various platforms, i.e. Maemo, Symbian, Windows, Mac, etc.. Stacked windows are Maemo specific, and any platform specific stuff is not enabled by default.


All times are GMT. The time now is 12:14.

vBulletin® Version 3.8.8