Results 1 to 6 of 6

Thread: centered text label

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2009
    Location
    San Francisco, CA
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default centered text label

    I have a QwtPlot where I want to place a label such that it is at a given coordinate on the y-axis but is always centered on the x-axis, even when the axis scale is updated. I'm really lame at this stuff, but I suspect that this would involve handling a "redraw()" method so that the x-position is recalculated. But I'm not sure.

    If I want to draw the label at a gtiven coordinate in both x and y, I do the following:
    Qt Code:
    1. text.setFont(QFont("Helvetica",24, QFont::Bold));
    2. text.setColor(text_color);
    3. QwtPlotMarker *label_mark;
    4. label_mark = new QwtPlotMarker();
    5. label_mark->setValue(x, y);
    6. label_mark->setLabel(text);
    7. label_mark->attach(thisPlot);
    To copy to clipboard, switch view to plain text mode 

    Simple. Is there something equally simple to have x instead be the center of the plot?
    Last edited by djconnel; 25th April 2009 at 23:51.

Similar Threads

  1. Replies: 15
    Last Post: 31st January 2020, 18:25
  2. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49
  3. how to append text in label
    By wagmare in forum Qt Programming
    Replies: 3
    Last Post: 12th March 2009, 11:06
  4. label with image and text
    By mattia in forum Newbie
    Replies: 1
    Last Post: 7th March 2008, 11:28
  5. Replies: 1
    Last Post: 24th October 2006, 16:40

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.