Results 1 to 8 of 8

Thread: rotate Qlabel inside a QPopupMenu

  1. #1
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default rotate Qlabel inside a QPopupMenu

    hi, I'm trying this but doesn't work; it doens' appear rotate; I'd like obtain something like first pic; the second is produced by this code...

    Qt Code:
    1. void myLabel::paintEvent( QPaintEvent *){
    2. p.begin( this );
    3. p.drawText(rect(), AlignCenter, "The Text" );
    4. p.rotate(40.0);
    5. p.end();
    6. }
    7.  
    8. MyPopupmenu::MyPopupmenu(MyWidget* parent, const char* name ):
    9. QPopupMenu( parent, name)/*, mywidget( parent )*/
    10. {
    11. insertItem(QPixmap::fromMimeSource("wireFrame.png"),
    12. "WireFrame", 0);
    13.  
    14. insertItem(QPixmap::fromMimeSource("zoom_in.png"),
    15. "Zoom in", 1);
    16. myLabel* l = new myLabel (this);
    17. insertItem(l,2);
    18. }
    To copy to clipboard, switch view to plain text mode 
    Attached Images Attached Images
    Last edited by mickey; 1st May 2006 at 11:55.
    Regards

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: rotate Qlabel inside a QPopupMenu

    Rotate first, then paint.

  3. #3
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: rotate Qlabel inside a QPopupMenu

    sorry, it happen this...the text isn't visible.
    Attached Images Attached Images
    Regards

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: rotate Qlabel inside a QPopupMenu

    Because it's centered inside rect() rectangle. Try Qt::AlignLeft.

  5. #5
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: rotate Qlabel inside a QPopupMenu

    sorry desn't work; in anyway the brown rect is background of QLabel...and it doesn't rotate...
    Attached Images Attached Images
    Regards

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: rotate Qlabel inside a QPopupMenu

    Quote Originally Posted by mickey
    in anyway the brown rect is background of QLabel...and it doesn't rotate...
    If you want to place that label vertically, QPainter::rotate() won't help you much --- you will have to create your own popup menu widget.

  7. #7
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: rotate Qlabel inside a QPopupMenu

    in Wich sense must I create a my own popup widget? In the sense below? Must I to put a FancyPopup on myQpopupmenu?

    Other thing: here below I'm trying to put fancypopup on myLabel; but fancypopup apper out my app; i set its parent mylabel. Does setGeometry (x,y...) set coordinates relative to parent? Why FancuPopup doesn't appear 10,10 inside myLabel?

    Qt Code:
    1. myLabel::myLabel (QWidget* parent, const char* name) : QLabel (parent,name) {
    2. this->setBackgroundColor(QColor(200,100,0));
    3. fp = new FancyPopup (this);
    4. fp->setBackgroundColor(QColor (200,200,200));
    5. fp->setGeometry(10,10,50,20);
    6. }
    To copy to clipboard, switch view to plain text mode 
    Regards

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: rotate Qlabel inside a QPopupMenu

    Quote Originally Posted by mickey
    in Wich sense must I create a my own popup widget? In the sense below? Must I to put a FancyPopup on myQpopupmenu?
    No, you must change MyPopupmenu so that it displays a vertical label (now it display label horizontally), but this might not be easy.

    You could add myLabel and QPopupMenu to QHBox, but you will have to alter widget flags for the QPopupMenu and QHBox. Another way is to use QMenuData instead of QPopupMenu.

Similar Threads

  1. Replies: 2
    Last Post: 20th January 2009, 07:13
  2. Rotate QLabel
    By shader76 in forum Newbie
    Replies: 9
    Last Post: 24th December 2007, 12:31

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.