QGraphicsAnchorLayout



  • Hello,

    I wrote a simple application based on QGraphicsView. I want a set of buttons on the upper right of the window. So I anchored a linear layout to the left. Consider this method.

    @void MainWindow::createLayout()
    {
    QGraphicsLinearLayout *leftLayout = new QGraphicsLinearLayout(Qt::Vertical);
    leftLayout->addItem(proxyForName["callMe"]);
    leftLayout->addItem(proxyForName["textMe"]);
    leftLayout->addItem(proxyForName["exitApp"]);

     QGraphicsAnchorLayout *aLayout = new QGraphicsAnchorLayout;
     aLayout->addAnchor(leftLayout,Qt::AnchorLeft,aLayout,Qt::AnchorLeft);
    
     QGraphicsWidget *widget = new QGraphicsWidget;
     widget->setLayout(aLayout);
     scene->addItem(widget);
    

    }@

    Looks great in the Qt Simulator. Unfortunately, it Qt centers these buttons on the target platform (ie, Symbian^1 - Nokia 5800 running Qt 4.6.3). Why does this layout behave so differently?

    -jk

    PS. Hmm.. to bad this forum doesn't allow me to upload an image. I wanted to show the resulting layout.



  • Hi,

    Cannot you upload the image to imagebin or something like that? It should not look different if the screen resolution and text are the same in the simulator and device.

    The layout you set should make the buttons remain at the left of the screen with their preferred size. You could also try removing the linear layout and using only the anchor one to try and see if it behaves differently. I mean, by anchoring each of the buttons to the left of the layout. Then one on top of the other, and finally glueing their right side together.

    br,

    Eduardo


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.