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. Problem drawing an Arrow using RArrow class (solved)
Forum Updated to NodeBB v4.3 + New Features

Problem drawing an Arrow using RArrow class (solved)

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.7k Views 2 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.
  • H Offline
    H Offline
    houmingc
    wrote on last edited by houmingc
    #1

    error:: expected primary-expression before ')' token

    Not able to draw an Arrow using rarrow class link as below:
    https://rittwik.wordpress.com/2012/08/29/rarrow-class-for-drawing-arrows/

    MainWindow::MainWindow
    {
    RArrow *Rarrow = new RArrow();
    Rarrow-> raDrawArrow(QPainter);
    }

    to create Head

    to create Rectangle.

    Amend RArrow constructor as follow :
    RArrow::RArrow()
    { raStartPoint = QPoint(5,5);
    raEndPoint = QPoint(40,40);
    raLineWidth = 20;
    raHeadHeight = 5;
    raBorderThickness =2 ;
    for( int i=0;i<7;i++)
    raArrowPoints[i]=QPointF(-1,-1);
    }

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by A Former User
      #2

      @houmingc said:

      Rarrow-> raDrawArrow(QPainter);

      You need to pass a pointer to the QPainter object you want to paint with. So, for example, if you want to draw on a custom widget then reimplement its paintEvent method like this:

      void SimpleExampleWidget::paintEvent(QPaintEvent *)
      {
          QPainter painter(this);
          painter.setPen(Qt::blue);
          painter.setFont(QFont("Arial", 30));
          painter.drawText(rect(), Qt::AlignCenter, "Qt");
          // ...
          RArrow *Rarrow = new RArrow();
          Rarrow-> raDrawArrow(&painter);
      }
      
      1 Reply Last reply
      0
      • H Offline
        H Offline
        houmingc
        wrote on last edited by houmingc
        #3

        It work.
        Can please briefly explain why pass a pointer QPainter object to the paint Object

        ---- To draw 3 arrow -----
        QPainter painter(this);
        Rarrow1->setStart(QPointF(100,110));
        Rarrow1->setEnd(QPointF(150,110));
        Rarrow1->raDrawArrow(&painter);

        Rarrow1->setStart(QPointF(160,110));
        Rarrow1->setEnd(QPointF(200,110));
        Rarrow1->raDrawArrow(&painter);

        Rarrow1->setStart(QPointF(250,110));
        Rarrow1->setEnd(QPointF(300,110));
        Rarrow1->raDrawArrow(&painter);

        ? 1 Reply Last reply
        0
        • H houmingc

          It work.
          Can please briefly explain why pass a pointer QPainter object to the paint Object

          ---- To draw 3 arrow -----
          QPainter painter(this);
          Rarrow1->setStart(QPointF(100,110));
          Rarrow1->setEnd(QPointF(150,110));
          Rarrow1->raDrawArrow(&painter);

          Rarrow1->setStart(QPointF(160,110));
          Rarrow1->setEnd(QPointF(200,110));
          Rarrow1->raDrawArrow(&painter);

          Rarrow1->setStart(QPointF(250,110));
          Rarrow1->setEnd(QPointF(300,110));
          Rarrow1->raDrawArrow(&painter);

          ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          Can please briefly explain why pass a pointer

          Because the website you linked to says so. :-) It says:

          After specifying these variables you can call the
          void raDrawArrow(QPainter *)
          function to draw the arrow using the QPainter.

          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