Page 1 of 2 12 LastLast
Results 1 to 20 of 29

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

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

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

    Hi all,

    i am having a confusion in rotating the main window(assume its my main menu window) with QT.
    but i cant find a single hint as to how to rotate it.

    My menu should look the same (i.e. only x ,y position of main window should be changed) after
    rotating it 90 degree.

    does any one has the hint or solution?i am using QT-4.6.2 with ARM .

    thanking all. please,reply ASAP.

  2. #2
    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?

    I am not sure what it is you want to rotate, the menu, or the main window?
    However, the answer is the same:
    You will have to re-implement the paintEvent() and use QPainter::rotate(),possibly in conjunction with QPainter::translate().
    ==========================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.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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?

    Do you want to rotate one window or you mean that you are rotating your device from landscape to portrait (or the other way round)?
    If the latter, does your device (or its OS to be exact) handle screen rotation automatically?
    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.


  4. #4
    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.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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.


  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 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.

  7. #7
    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...

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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.


  9. #9
    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.

  10. #10
    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.

  11. #11
    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.

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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.


  13. #13
    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.

  14. #14
    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.

  15. #15
    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.

  16. #16
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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?

    It definitely won't work this way because of several reasons, one of them being the fact that you create the scene as a local object that gets destroyed when the function ends. I take it that you still don't understand the whole concept of Graphics View and embedding widgets inside it. You should read about it first before doing something practical. A hint - if you want to embed your main window into GV, it should be embedded in it all the time, not only when you want to rotate it.
    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.


  17. #17
    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?

    Look, you problem is basic C++, and we can't help you with that.

    The problem in the code is that your scene and view are local variables, and the die at the end of the function scope.

    [EDIT]: beat to it by wysota..
    ==========================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.

  18. #18
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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?

    Quote Originally Posted by high_flyer View Post
    [EDIT]: beat to it by wysota..
    Sorry...
    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.


  19. #19
    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?

    Thanks to all.

    I have rotated my main Widget with all other objects indise it.So,now when the application runs ,
    it gives me rotated Main Widget which fits to the screen of 480*800.

    But,the problem is that when i rotate my Main widget to the 90*,it shows scroll bar on left and
    bottom area. Which i dont want. one more thing,when i dont rotate it 90*,it doesnt show the
    scroll bar.

    i have also verified ,if any object gets out of the Main widget geometry. and its not going out of
    that.Does any one know why this is happening? please reply me soon.

  20. #20
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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?

    Quote Originally Posted by savaliya_ambani View Post
    But,the problem is that when i rotate my Main widget to the 90*,it shows scroll bar on left and
    bottom area. Which i dont want.
    So disable them.

    i have also verified ,if any object gets out of the Main widget geometry. and its not going out of
    that.Does any one know why this is happening? please reply me soon.
    Could you express yourself more clearly? I have trouble understanding what you mean.
    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.


Similar Threads

  1. Replies: 11
    Last Post: 11th August 2008, 10:14
  2. Main Window
    By sabeesh in forum Qt Programming
    Replies: 1
    Last Post: 6th August 2007, 08:32
  3. Replies: 15
    Last Post: 23rd March 2007, 17:16
  4. Getting main window to run.
    By Doug Broadwell in forum Newbie
    Replies: 5
    Last Post: 18th October 2006, 00:56
  5. Main window
    By Michiel in forum Qt Tools
    Replies: 1
    Last Post: 21st March 2006, 00: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.