Results 1 to 3 of 3

Thread: Aligning 2 plots

  1. #1
    Join Date
    Feb 2013
    Posts
    4
    Thanks
    1

    Default Aligning 2 plots

    Hi guys,

    I am new to QT and QWT. I currently have 2 spectrogram plots in a vertical layout. The top one has a scrolling time y axis (adapted from the cpuplot example). The bottom one has a predefined y axis. I am trying to align the 2 plots' x-axis.
    Basically, I think i would need to get the label size of top scaledraw and somehow apply it to the bottom plot but not sure how to do this. Any help (or if theres a better way to align two graph axes) would be much appreciated.

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,274
    Thanked 868 Times in 817 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Aligning 2 plots

    First you need to align the y axes.

    Qt Code:
    1. int extent = plot1->axisWidget( yLeft )->scaleDraw()->extent( plot1->axisWidget( yLeft )->font() );
    2. plot2->axisWidget( yLeft )->scaleDraw()->setMinimumExtent( extent );
    3. plot2->setAxisScaleDiv( xBottom, plot1->axisScaleDiv( xBottom ) );
    To copy to clipboard, switch view to plain text mode 
    A scale widget emits a signal scaleDivChanged() whenever its scale has been modified.

    Uwe

  3. The following 2 users say thank you to Uwe for this useful post:

    jerrychan (25th February 2013), lextr (27th May 2013)

  4. #3
    Join Date
    Feb 2013
    Posts
    4
    Thanks
    1

    Default Re: Aligning 2 plots

    It works great, thank you very much for the prompt reply!

Similar Threads

  1. qwt plots & inheritance
    By fatecasino in forum Qwt
    Replies: 1
    Last Post: 14th December 2010, 14:35
  2. Replies: 3
    Last Post: 15th May 2010, 18:48
  3. Aligning widgets in different layouts
    By negritot in forum Qt Tools
    Replies: 4
    Last Post: 9th March 2009, 16:07
  4. Aligning message displayed on QStatusbar
    By sanjayshelke in forum Qt Programming
    Replies: 2
    Last Post: 20th November 2008, 09:41
  5. Aligning a stringlist
    By impeteperry in forum Qt Programming
    Replies: 1
    Last Post: 22nd May 2006, 17:45

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.