Active Topics

 


Reply
Thread Tools
Guest | Posts: n/a | Thanked: 0 times | Joined on
#1
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:

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?

Last edited by XenGi; 2011-03-16 at 10:04.
 
Posts: 172 | Thanked: 193 times | Joined on Nov 2009 @ Germany
#2
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.

Last edited by percy; 2011-03-16 at 10:08.
 
Guest | Posts: n/a | Thanked: 0 times | Joined on
#3
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.

Last edited by XenGi; 2011-03-16 at 10:21.
 
Posts: 172 | Thanked: 193 times | Joined on Nov 2009 @ Germany
#4
Originally Posted by percy View Post
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':

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.
 
Guest | Posts: n/a | Thanked: 0 times | Joined on
#5
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.
 
Posts: 172 | Thanked: 193 times | Joined on Nov 2009 @ Germany
#6
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?
 
Guest | Posts: n/a | Thanked: 0 times | Joined on
#7
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.
 
Reply


 
Forum Jump


All times are GMT. The time now is 09:54.