Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Why is width important in tickers (solve)

    General and Desktop
    1
    1
    414
    Loading More Posts
    • 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.
    • H
      houmingc last edited by

      code is in this link http://www.qtforum.org/article/26964/how-to-comprehend-this-example.html
      i don't understand why width is tested here, why not use a timer?

      @
      void Ticker::paintEvent(QPaintEvent * /* event */)
      {
      QPainter painter(this);

      int textWidth = fontMetrics().width(text());
      if (textWidth < 1)
          return;
      int x = -offset;
      while (x < width()) {
          painter.drawText(x, 0, textWidth, height(),
                           Qt::AlignLeft | Qt::AlignVCenter, text());
          x += textWidth;
      }
      

      @

      [edit: added missing coding tags @ SGaist]

      1 Reply Last reply Reply Quote 0
      • First post
        Last post