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. Update after moving qgraphicstextitem
Qt 6.11 is out! See what's new in the release blog

Update after moving qgraphicstextitem

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 286 Views
  • 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.
  • I Offline
    I Offline
    IknowQT
    wrote on last edited by IknowQT
    #1

    82faf340-481c-4fa4-ba1a-dd23ca053347-image.png

    The graph was moved with the mouse, and the textitem was also moved according to the graph. The bottom textitem is cut off to the screen.
    But what's strange is that when I click or switch to another screen, it works normally.

    for (int i = 0; i < this->series().count(); i++)
    	{
    		usrLineSeries* pSeries = qobject_cast<usrLineSeries*>(this->series().at(i));
    
    		if (pSeries)
    		{
    			foreach(auto item, pSeries->GetTextItems())
    			{
    				if (!bItemVisible)
    				{
    					item->setVisible(bItemVisible);
    				}
    				else
    				{
    					QPointF target(item->GetOriPos());
    					QPointF p = this->mapToPosition(QPointF(target), pSeries);
    
    					if (!this->plotArea().contains(p))	// 화면 벗어나면 visible 안함
    						item->setVisible(false);
    					else
    					{
    						QPointF sPos = this->mapToScene(p.x(), p.y());
    						item->setPos(sPos.x(), sPos.y());
    						item->setVisible(bItemVisible);
    					}
    				}
    			}
    		}
    	}
    
    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