Reply
Thread Tools
Posts: 24 | Thanked: 9 times | Joined on Jul 2010 @ Vicenza (Italy)
#1
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

Last edited by mmichielin; 2010-07-22 at 09:09.
 
Posts: 219 | Thanked: 94 times | Joined on Nov 2009 @ Helsinki, Finland
#2
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.
Attached Images
 
__________________
Ham > Turkey
 

The Following User Says Thank You to naabi For This Useful Post:
Posts: 24 | Thanked: 9 times | Joined on Jul 2010 @ Vicenza (Italy)
#3
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:n_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
 
Posts: 388 | Thanked: 842 times | Joined on Sep 2009 @ Finland
#4
Originally Posted by mmichielin View Post
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

Last edited by hqh; 2010-07-22 at 10:11.
 

The Following 4 Users Say Thank You to hqh For This Useful Post:
Posts: 24 | Thanked: 9 times | Joined on Jul 2010 @ Vicenza (Italy)
#5
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
 
Posts: 388 | Thanked: 842 times | Joined on Sep 2009 @ Finland
#6
Originally Posted by mmichielin View Post
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.
 

The Following User Says Thank You to hqh For This Useful Post:
Posts: 24 | Thanked: 9 times | Joined on Jul 2010 @ Vicenza (Italy)
#7
Originally Posted by hqh View Post
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's Avatar
Posts: 1,296 | Thanked: 1,773 times | Joined on Aug 2009 @ Budapest, Hungary
#8
 
Posts: 219 | Thanked: 94 times | Joined on Nov 2009 @ Helsinki, Finland
#9
Originally Posted by mmichielin View Post
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.
__________________
Ham > Turkey
 
Reply


 
Forum Jump


All times are GMT. The time now is 02:40.