PDA

View Full Version : [Symbian] Show widgets maximized on different resolutions



tryinghard
9th January 2011, 23:44
Hi,

i'm trying to develop an application for symbian with QT. I'm having problems displaying widgets maximized in different resolutions.

Lets say i have one QMainWindow and few QWidgets. One of the QWidgets is called BrandTabs

In QMainWindow i do:


BrandTabs* tabs = new BrandTabs(this, this->dbManager);
tabs->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
tabs->showMaximized();
setCentralWidget(tabs);


BrandTabs has a QVBoxLayout, inside it a QTabWidget and inside first tab again QVBoxLayout with QListWidget.

QTabWidget, QListWidget have their size policies set to QSizePolicy::MinimumExpanding.

But still, thei are not maximed if resolution is bigger than defined in editor (i'm using QT creator).

Any hints, thanks :)

Zlatomir
10th January 2011, 00:03
Why do you show that tabs and not the mainWindow (since tabs is the central part of a mainWindow)?
You should have something like this (in your main.cpp):


int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w; //replace MainWindow with the name of your mainwindow class

w.showMaximized();

return a.exec();
}

tryinghard
10th January 2011, 00:07
Well my main window has other UI elements (buttons, images, etc) and on one of those buttons click, BrandTabs widget should be shown only. Or maybe this is incorrect approach?

Zlatomir
10th January 2011, 00:18
showMaximized() (http://doc.qt.nokia.com/4.7/qwidget.html#showMaximized) only affects windows, so that is not ok.
That tabs is supposed to become a new window or show() inside mainWindow?

tryinghard
10th January 2011, 00:21
Tabs should become the only component on the screen, no other components from previous widgets or windows. My initial idea is that i would have many QWidgets, and simply swap in with setCentralWidget. But now i have fullscreen problem :) Or should i have many QMainWindows and somehow display them ?

Zlatomir
10th January 2011, 00:36
Then derive your tabs widget from QDialog and use exec() to show it modal on top of the mainwindow, or showMaximized().
Also you can derive from QMainWindow (you can make it modal and maximized too).

LE: and of-course you shouldn't set it as a central widget in mainWindow.

LE2: also creating there an new and empty QDialog/QMainWindow and use that as a parent for tabs should work (and then showMaximized() or whatever is apropiate)

tryinghard
10th January 2011, 00:57
Thanks! Last question i guess :) Lets say from a list in tabs, i want to show a map control (again fullscreen, no other inputs). Options are the same as i understand - either use QMainWindow, or QDialogs? And if want to handle user navigating back, i simply close those QDialogs, and that is it?

Edit:

ok, QDialog solution does not work or i am doing something really wrong. I've created class that derives from QDialog with QT Creator. Added a QVBoxLayout inside it, then QTabWidget and inside first tab QVBoxLayout and then QListView. QSizePolicy is set for all (MinimumExpanding). And no good... it takes up space that it has in the designer, and does not maximize.

Tried without QVBoxLayout - the same. I think the main QDialog is maximized, but QTabWidget inside it - no.

Zlatomir
10th January 2011, 01:31
Well that is a solution, but you also must think about your users (i wouldn't like to open a lot of dialogs, and then make a check a checkbox and close them again), well now 3 isn't quite a lot, but don't exaggerate with that ;)
So think of other solutions that fit the problems you are trying to solve.

Show/hide Widgets is another solution, it really depends on what are you trying to do, so just try think as a user too ;)

I'm not sure if you can replace/show/replace the centralWidget of a mainWindow, but you can definitely show/hide widgets from the centralWidget and if you play with sizePolicy you can even have a nice dynamic ui (the widgets can expand or remain the same size related to what changes in ui)

LE: then post a little project (a compilable example) that show your problem, archive the project and attach it here so we can have a look on what are you doing wrong...

As i said in one edit to my previous post you don't necessary need to subclass QDialog, you can just create a QDialog on the heap (give the original mainWindow pointer as a parent to the new dialog) then create your tabs and give the new dialog as a parent (and delete setCentralWidget(tabs) of the original mainWindow... or put whatever necessary in there)
Then show the new QDialog when ever is appropriate for you...

tryinghard
10th January 2011, 11:07
I think that problem is with QT Creator. As i am using visual designer, it generates its own header files (aka ui_brandtabs.h) and in those files there is a call to setGeometry().

Will try to create sample project and upload it here.

Added after 18 minutes:

ok, made a sample application. As i understand, the list should be displayed full screen, though it does not.

Thanks again :)

Zlatomir
10th January 2011, 15:53
You just need to add layouts to the form itself too (if you use the Designer this is done by selecting the background Form and then press the button for the needed layout.
See the attachment, it should be working fine ;)
Also a recommended reading Layout management documentation (http://doc.qt.nokia.com/4.7/layout.html)

tryinghard
10th January 2011, 22:20
Thanks!!!!! Superb, works like a charm :)