×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    49

    QGraphicsViev / QgraphicsScene size

    hello
    I want to write something independent from device screen size. I want set position of icons on QGraphicsScene. I have to know the scene size in order to all icons set on the device screen (without scrollbar). Unfortunately I have no idea how to do it - how to get size of scene that cover screen. Could you help me?

  2. #2
    Regular Contributor
    Join Date
    Mar 2009
    Posts
    430

    Re: QGraphicsViev / QgraphicsScene size

    Use QDesktopWidget.

  3. #3
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: QGraphicsViev / QgraphicsScene size

    Code:
    QApplication::desktop()->availableGeometry(QCursor::pos());

  4. #4
    Registered User
    Join Date
    Oct 2008
    Posts
    49

    Re: QGraphicsViev / QgraphicsScene size

    Yours code give me size of the screen, but how to translate this to QGraphicsScene?

    I have something like this:
    Code:
    QGraphicsScene *scene = new QGraphicsScene();
    w.addScene(scene); //w is QGraphicsView
    Icons *i1=new Icons(QPixmap(":/guitestm2/nuclear.png"));// Icons is my class inherit QGraphicsWidget
    i1->setGeometry(QRectF(0, 0, 50, 50));
    scene->addItem(i1);
    w.showMaximized();
    And for examplme I have no idea how to put i1 to right - down corner of the screen

  5. #5
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: QGraphicsViev / QgraphicsScene size

    Code:
    i1->setPos((QApplication::desktop()->availableGeometry(QCursor::pos())).bottomRight() - QPoint(i1->width(), i1->height()));
    Last edited by divanov; 2010-02-06 at 00:05.

  6. #6
    Registered User
    Join Date
    Oct 2008
    Posts
    49

    Re: QGraphicsViev / QgraphicsScene size

    Unfortunately your code did not produce property value.
    Your code give x=189 y=269 and the icon unseen on the screen, i have to use scrollbars to see it.
    The property( I check it by hand after few try) value for right bottom corner is aproximately x=150 y=180 for icon width=height=50

  7. #7
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: QGraphicsViev / QgraphicsScene size

    Quote Originally Posted by Estel View Post
    Unfortunately your code did not produce property value.
    Your code give x=189 y=269 and the icon unseen on the screen, i have to use scrollbars to see it.
    The property( I check it by hand after few try) value for right bottom corner is aproximately x=150 y=180 for icon width=height=50
    Do you have anything else except of QGraphicsView inside your window? Is 239x319 correct available geometry?

  8. #8
    Registered User
    Join Date
    Oct 2008
    Posts
    49

    Re: QGraphicsViev / QgraphicsScene size

    I have only GraphicsView, I have put it using qt designer and the sizePolicy is expanding.
    For my phone coordinates of right-bottom corner in graphicsScene are(aproximately, +/- 5) x=205 y=237, I have just added some item and check when it disapeard from the screen.

  9. #9
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: QGraphicsViev / QgraphicsScene size

    Code:
    #include <QApplication>
    #include <QGraphicsView>
    #include <QGraphicsScene>
    
    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
    
        QGraphicsScene scene;
    
        QGraphicsView view(&scene);
        view.show();
    
        QRectF geometry = view.contentsRect();
        scene.addLine(QLineF(geometry.topLeft(), geometry.bottomRight()));
        scene.addLine(QLineF(geometry.bottomLeft(), geometry.topRight()));
    
        return app.exec();
    }
    Last edited by divanov; 2010-02-07 at 09:40.

  10. #10
    Registered User
    Join Date
    Oct 2008
    Posts
    49

    Re: QGraphicsViev / QgraphicsScene size

    Code:
    QRectF geometry = view.contentsRect();
    It works excelent
    Thank you very much for yours time.

Similar Threads

  1. Weird Problem with find box Kern-Exec-3
    By sohilr in forum Symbian
    Replies: 7
    Last Post: 2007-12-05, 04:10
  2. KERN-EXEC 3 with CEikEdwin
    By acarrion in forum Symbian User Interface
    Replies: 3
    Last Post: 2007-10-17, 14:43
  3. Audio Input Stream on N80
    By tkaihock in forum Symbian Media (Closed)
    Replies: 9
    Last Post: 2006-06-30, 09:15
  4. The correct meaning of MAX JAR size
    By bigrio in forum Mobile Java General
    Replies: 0
    Last Post: 2004-11-13, 11:03
  5. User break point error in Grid
    By ag24master in forum Symbian User Interface
    Replies: 0
    Last Post: 2003-08-07, 08:20

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×