Resizing problems. ):



  • Hi. I'm having trouble doing the whole layout of 1920x1080 on my desktop.
    Anyone have any idea on how to resize when previewing it? Like is there any code to fit my whole layout according to different type of screensize?



  • Did you not get the question. Can you be bit clear and copy any sample code if possible.



  • We are designing for a 1920x1080 screen resolution, and this is the code we use to set the whole body size.

    @id: mainWindow
    width: 1920
    height: 1080
    color: "#000000"
    anchors.fill: parent@

    This is the result of the preview:

    !http://i1080.photobucket.com/albums/j326/dancexpression/problem1.png(Example)!

    We want this thing to work in different screen sizes. So is there any code to make it fit to screen?

    Thanks!



  • If you want to show your application full screen you might use QWidget::showFullScreen() (see the documentation for details). In addition, you might grab your screens geomerty using QDesktopWidget::screenGeometry() and resize the widget by yourself.

    If you want your QML application to be fullscreen remove the width and height attributes and set the resize mode of the QDeclarativeView to QDeclarativeView::SizeRootObjectToView.

    @
    view.setResizeMode(QDeclarativeView::SizeRootObjectToView);
    view.setGeometry(application.desktop()->screenGeometry());
    @

    You probably need to set some window flags correctly (eg. Qt::FramelessWindowHint | Qt::Tool | Qt::WindowStaysOnTopHint)



  • About reply should have helped you. Basically you don't need to specify your mainWindow sizde in qml file.

    I use below code generally

    @ QmlApplicationViewer viewer;
    viewer.setMainQmlFile(QLatin1String("qmlfilerelativepath"));
    viewer.setResizeMode(QDeclarativeView::SizeRootObjectToView);
    viewer.showFullScreen();
    @

    The code is self explainable.



  • Hi thanks for the reply. However when i tried using the codes given, and error occured.

    It says: 'view' was not declared in this scope



  • The documentation about QWidget::showFullScreen() says that ...
    @
    Full-screen mode works fine under Windows, but has certain problems under X. These problems are due to limitations of the ICCCM protocol that specifies the communication between X11 clients and the window manager. ICCCM simply does not understand the concept of non-decorated full-screen windows. Therefore, the best we can do is to request a borderless window and place and resize it to fill the entire screen. Depending on the window manager, this may or may not work. The borderless window is requested using MOTIF hints, which are at least partially supported by virtually all modern window managers.
    @

    I wonder if anyone ever faced such problems.



  • [quote author="imma_intern" date="1308216761"]Hi thanks for the reply. However when i tried using the codes given, and error occured.

    It says: 'view' was not declared in this scope[/quote]

    'view' is the name of a QWidget (or a subclass) or a QmlApplicationViever, however it may be named in your application. See Vijay's example, this should work fine for you.



  • we tried with both of the codes, and we got the same error.



  • Do you include QmlApplicationViewer header file in your cpp file ?
    Hi, this header file is generated as a part of qt quick project ( with c++ class integration) creation in Nokia Qt SDK 1.1.



  • Ok.. seems this have a problem. I tried the below code and seems to work. Can you try..

    @
    

    #include <QDeclarativeView>
    QDeclarativeView *viewer = new QDeclarativeView;
    viewer->setSource(QUrl::fromLocalFile("qml/Example/main.qml"));
    viewer->setResizeMode(QDeclarativeView::SizeRootObjectToView);
    viewer->showMaximized();@

    And in your main.qml, give some default size to your main item. If you don't specify any side to root item, the main window is not displayed at all.

    main.qml

    @
    Item {
    height: 100; width: 100 // some default
    .......
    }
    @

    This is strange that showFullScreen() in QWidget ( I mean QDeclarativeView) does not work.


Log in to reply
 

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