Results 1 to 20 of 29

Thread: Challenge + confusion while rotating main window with QT?how to do?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2010
    Posts
    100
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Challenge + confusion while rotating main window with QT?how to do?

    Dear high_flyer and wysota,

    Thanks for your Reply.

    let me clear my self about my goal.I want to rotate my main window,the MainWindow which gets generated from UI.
    when certain event occurs (may be timer event or pushbutton clicked),my main window should show me the rotation
    of 90* degree.

    you said me, i have to use paintEvent() and use QPainter::rotate(),possibly in conjunction with QPainter::translate().
    but as i am naive to this,can you please show me the function code or example application,so that i can proceed further in my development.

    Need Quick reply,

    with regards Mukesh Savaliya.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Challenge + confusion while rotating main window with QT?how to do?

    Regular widgets can't be rotated just like that. You can do that through Graphics View (by placing the widget inside a scene).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    May 2010
    Posts
    100
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Challenge + confusion while rotating main window with QT?how to do?

    dear wysota,

    regular widget means what? can i say my main widnow a regular widget? And hence as u said can't i rotate my main window on pushbutton clicked?

    And should i proceed with the QPainter class and rotate ,translate function uses?

    please,give me the clear direction .

    thanks.

  4. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Challenge + confusion while rotating main window with QT?how to do?

    On rotation you want the text also to rotate 90 degree ? You wont be able to read it then, isnt it ?

    Regular widgets means classes derived from QWidget except for QGraphicsView. The items / widgets you add in a QGraphicsScene can be rotated easily. Thats what wysota said about.
    Have a look at graphics view examples in Qt Demos...

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Challenge + confusion while rotating main window with QT?how to do?

    QGraphicsView can't be rotated as well, only its contents can
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    May 2010
    Posts
    100
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Challenge + confusion while rotating main window with QT?how to do?

    Dear All,

    When i create a project, my MainWindow gets derived from the QWidget class,so i can use the function inherited from the QWidget. And i am able to change the geometry of my main window on PushButton clicked, inside function

    OnPushButtonClicked()
    {
    this->setGeometry(0,0,800,480) ;
    }

    But, i am not able to derive MainWindow from the QGraphicsItem/QPinter class. If you know ,please reply me soon.
    if thats possible,than i think i will be able to do this->setRotation(90*);.

    thanks to all.

  7. #7
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Challenge + confusion while rotating main window with QT?how to do?

    @savaliya_ambani:
    Lets make some order in things:
    1. It is clear you are a novice, hence what I suggested at first (overloading painEvent() and rotating the widget) is beyond what you can do at the moment, since its not trivial as wysota stated (but possible!)
    2. You didn't answer wysotas question - if you are working on a mobile or embedded dvice, that supports screen rotation - and that is very important.
    If you are working on a device that has a system that automatically rotates the screen, you are on the wrong path.
    3. If you really need to rotate your widget your self (which means, the screen or desktop stays non rotated) then the solution with QGraphicsView is probably the best, but it seems your abilities both with C++ and Qt are not sufficient (based on your questions so far).
    Never the less, what aamer4u and wysota meant with this is, that you should embed you widget in to a QGraphiceView.
    You will have to read about it in the documentation here:
    http://doc.trolltech.com/4.6/graphic...graphicswidget
    look for "Embedded Widget Support"
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  8. #8
    Join Date
    May 2010
    Posts
    100
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Challenge + confusion while rotating main window with QT?how to do?

    high_flyer,

    you are right,as i am very newbie to Qt. And also in learning pshase of the qt.
    let me tell you i am working on a embedded device with ARM9 controller,which has a touch sense 480*800 TFT,
    and i dont know whether it supports the automatic rotation.

    My intention was to find whether its possible to rotate the main window?
    And after this much disscussion i think its possible. but may take time as i am learning it.


    suggestions are welcome


    Thanks.

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Challenge + confusion while rotating main window with QT?how to do?

    Let's start from the beginning...

    Why do you want to rotate the window? I mean what is your intention of doing that, I'm not asking what should trigger the rotation.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #10
    Join Date
    May 2010
    Posts
    100
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Challenge + confusion while rotating main window with QT?how to do?

    dear wysota,

    i want to rotate the window,because of very simle reason. My TFT screen is of 480(h)*800(w). And you know it is connected with the ARM board. Now in my final product i want to attach TFT in 800(h)*480(w). i.e. original TFT will be
    rotated 90* and than fixed with the final product.

    And i cant design my GUI for 800*480(w) because original design on my PC will be for 480(h)*800(w).I have to rotate my head to 90* for designing the GUI and all the text form. And its deficult. i hope you got what i mean to say.

    thanks.

  11. #11
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Challenge + confusion while rotating main window with QT?how to do?

    And i cant design my GUI for 800*480(w) because original design on my PC will be for 480(h)*800(w).I have to rotate my head to 90* for designing the GUI and all the text form. And its deficult. i hope you got what i mean to say.
    You can size your widgets based on screen resolution. Check Digiflip example for mobile...it works in both landscape and potrait mode on a mobile.

    Also may be you can cleverly use layouts and design on 480*800. The even if you change direction, things might work. Install the Nokia Qt SDK and check how they do it in simulator.

  12. #12
    Join Date
    May 2010
    Posts
    100
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Challenge + confusion while rotating main window with QT?how to do?

    Hi,all,


    I have tried this to rotate my main window with the member function void rotateimage();
    i am calling this function on pushbutton cliked event.

    on_pushbuttonclicked_event()
    {
    this.rotateimage();
    }


    MainWindow::void rotateimage()
    {
    QGraphicsScene scene;
    QGraphicsProxyWidget *proxy=scene.addWidget(this);

    QGraphicsView view(&scene);
    view.rotate(90);
    view.show();
    }

    This gets compiled ,but when i execute it ,it flashes for a moment and ends with showing some errors is lib*.so.*
    program finished with unexpeted error.

Similar Threads

  1. Replies: 11
    Last Post: 11th August 2008, 09:14
  2. Main Window
    By sabeesh in forum Qt Programming
    Replies: 1
    Last Post: 6th August 2007, 07:32
  3. Replies: 15
    Last Post: 23rd March 2007, 16:16
  4. Getting main window to run.
    By Doug Broadwell in forum Newbie
    Replies: 5
    Last Post: 17th October 2006, 23:56
  5. Main window
    By Michiel in forum Qt Tools
    Replies: 1
    Last Post: 20th March 2006, 23:54

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.