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. Dynamically grow a widget into negative values.
Forum Updated to NodeBB v4.3 + New Features

Dynamically grow a widget into negative values.

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

    Hello the following code will do a pretty good job at growing a widget dynamically; that has been placed in a QScrolArea object, using setMinimumSize(). However this is probably not the best solution to do this and isn't a solution at all to grow the widget in a negative fashion thus increasing space in my upper and left regions.

    to Give more information when I drag a widget in a parent widget that is housed in the QScroll Area, I want my parent widget geometry to grow in a negative direction (top and left) and have my QScrollArea increase in negative amounts.

       QPoint TL = aCustomWidget->pos();
       int widthCord = TL.x() + aCustomWidget->width();
       int heightCord = TL.y() + aCustomWidget->height();
       QPoint BR(widthCord, heightCord);
       if(BR.x() > this->width()-10 || BR.y() > this->height()-10) 
       {
           QRect oldGeo = this->geometry();
           this->setGeometry(oldGeo.x(), oldGeo.y(), oldGeo.width()+5, oldGeo.height()+5); 
           int sizerX = abs(this->x())+this->width();
           int sizerY = abs(this->y())+this->height();
           setMinimumSize(sizerX, sizerY)
     }
    
    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