maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   strange behaviour - qt hbox width only half the screen (https://talk.maemo.org/showthread.php?t=71097)

XenGi 2011-03-16 09:44

strange behaviour - qt hbox width only half the screen
 
Hi I'm developing an apllication in Qt.
The source code can be viewed here: http://xengi.ath.cx/trac/autag/browser/tags/testing
A screenshot of the behaviour: http://img148.imageshack.us/i/screen...031609571.png/http://i56.tinypic.com/2nhon4y.png

I made a QHBoxLayout and added 2 QPushButtons ("FolderUp" and "Home"). The buttons alignment is justified by default so they should fill the hole width, each button 50%.
But they don't each button is 25% of the screen and I have no idea why.
On the Screenshot I have aligned the buttons left and right.

Any suggestions?

percy 2011-03-16 10:03

Re: strange behaviour - qt hbox width only half the screen
 
Does it work if you skip the PLLayout and use the 'layoutLandscape ' directly via

Code:

centralWidget->setLayout(layoutLandscape );

Edit: It seems problematic for me that the hbox layout is used in layoutLandscape and layoutPortrait. So there are 2 layout working on hbox.

XenGi 2011-03-16 10:19

Re: strange behaviour - qt hbox width only half the screen
 
I edited mainwindow.ccp like that:
Code:

void MainWindow::selfAssignLayout()
{
centralWidget = new QWidget();
//centralWidget->setLayout(autoLayout);
QHBoxLayout *htest = new QHBoxLayout();
centralWidget->setLayout(htest);
htest->addWidget(new QPushButton("test"));
htest->addWidget(new QPushButton("test"));
this->setCentralWidget(centralWidget);
}

that works perfect so the PLLayout stuff seems to make something wrong but thats not from me. It's from forum.nokia.com so I thought it should work.

The hole PLLayout class has no sizing stuff in it, so I really on't know whats the reasing for this.

percy 2011-03-16 10:42

Re: strange behaviour - qt hbox width only half the screen
 
Quote:

Originally Posted by percy (Post 968806)
Edit: It seems problematic for me that the hbox layout is used in layoutLandscape and layoutPortrait. So there are 2 layout working on hbox.

Looking at the documentation of QLayout it says under 'addItem':

Quote:

Note: The ownership of item is transferred to the layout, and it's the layout's responsibility to delete it.
So this could be one of the problems you are facing (assuming that it's the same for addLayout). I would work from your working solution slowly backwards until it doesn't work anymore. Then you should be close to the problem.

That's at least how I do in in my projects. :)

I would assume that the PLLayout class is working as desired but you are using it the wrong way or your own layout stuff has a bug.

XenGi 2011-03-16 10:58

Re: strange behaviour - qt hbox width only half the screen
 
I have the PLLayout stuff from here: http://wiki.forum.nokia.com/index.ph...n_layout_in_Qt

There is only one textbox but it is used in landscape and in portrait layout. So i thought I should use my hboxes and pushbuttons in both layouts too. The problem if I make every button 2 times, one for each layout is that if the layout changes the button you clicked is not the same. Or in other words... you enter some text in a textbox rotate the device and your text is away.
sure I could transfer the user input to the other layout on rotate but I think this PLLayout stuff is not intended to be used in that way.

percy 2011-03-16 12:16

Re: strange behaviour - qt hbox width only half the screen
 
Hmm, in the example they use eventFilter(QObject *obj, QEvent *event) and you are using resizeEvent(QResizeEvent* event).

Do you get the resize event? And have you checked that their simple example with 4 buttons is working?

XenGi 2011-03-17 11:20

Re: strange behaviour - qt hbox width only half the screen
 
I don't know, never tested it.

But I've abbonded the idea of auto orientation in my program because it's unhandy to use it in portrait mode.

So I deleted all the PLLayout stuff.

but thanks for your help. I will continue working on that problem when I do my next program. Maybe I write my own solution for nice auto orientation. I have some ideas already in this direction.

If you are interested you can checkout the current state of AuTag. Any help or suggestions would be cool. Feedback is always good. ;)


All times are GMT. The time now is 16:30.

vBulletin® Version 3.8.8