Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to apply rotation property for custom widget plug-in.
Forum Updated to NodeBB v4.3 + New Features

How to apply rotation property for custom widget plug-in.

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 498 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    amitgolhani
    wrote on last edited by
    #1

    Hi,

    I have prepared rectangle custom widget plugin and integrated it into qt designer. I want to write rotation property for the rectangle widget. I am using QPainter:: drawRect() and QPainter:: rotate(int angle) API to achieve the same. As for as I increase the angle of QPainter:: rotate(int angle) API, then the rectangle widget hide behind selection box of qt designer.

    Is another way in Qt to auto adjust the selection box of qt designer according to change in angle?
    How will I achieve the same. Please suggest me.

    Sample code is:

    void Rect::paintEvent(QPaintEvent *event)
    {
         QPainter painter(this);
        
         int left = 100;
         int top = 50;
         int width = 200;
         nt height = 150;
    
         QRect r1(left, top, width, height);
         painter.setPen(Qt::blue);
         painter.rotate(90);
         painter.drawRect(r1);
    }
    

    Thanks

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      Im not sure what "selection box of qt designer" is.

      I think what u are seeing is clipping.

      A Widgets has an area (client area). You cannot draw outside this area. (in paintevent)

      Since you are just rotating HOW you draw, and not the actual widget itself then
      you see it being cutted.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved