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. Qwidget height() and width() changing

Qwidget height() and width() changing

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 614 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.
  • D Offline
    D Offline
    Drj312
    wrote on last edited by
    #1

    I'm trying to learn how to draw using QPainter. I'm basing the renderarea class off the basic drawing example. I'm making a QPainterPath with this
    @ void RenderArea::Path()
    {
    path.moveTo(150,0);
    path.lineTo(150,height());
    update();
    }@

    and then
    @
    void RenderArea::paintEvent(QPaintEvent * /* event */)
    {
    QPainter painter(this);
    painter.drawPath(path);
    }
    @
    The issue is that when I click the push button that triggers Path(), the first time it runs, the line does not extend the entire height of the renderarea widget. The same happens if I try to draw across using width(). However, if I click the push button again, height() and width() will extend across the widget as expected. What am I missing? I don't understand why height() and width() change.

    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