Results 1 to 4 of 4

Thread: QwtMatrixRasterData - setting a fixed column width

  1. #1
    Join Date
    Mar 2012
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Question QwtMatrixRasterData - setting a fixed column width

    I'm generating a plot like the rasterview example. Sometimes my users data only has one column of information. By default qwt will spread this column out over the entire plot area. So the data always takes up the same width if there is one column or 50 columns. Is there a way to set the width of the columns without also scaling the color map and axes data. I would like to solve this for the screen, exporting to a pdf, and for printing.

    This is what I'm getting:
    DoNotWantItWide.jpg

    This is what I want:
    WantItNarrow.jpg
    Thanks
    Buffy

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

    Default Re: QwtMatrixRasterData - setting a fixed column width

    It's the application ( your ! ) code that is responsible for the geometry of the plot widget. See QLayout, QWidget::setGeometry ...

    Uwe

  3. #3
    Join Date
    Mar 2012
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Question Re: QwtMatrixRasterData - setting a fixed column width

    Uwe,
    Thank you very much for your input but I still seem to be missing something. My original problem was I was not setting the alignment when I called addWidget so the layout was stretching my data and not paying attention to the geometry I was trying to set.

    Now I'm setting the geometry and minimum width for the widget and adding the widget with an alignment so that it doesn't stretch to take up the entire space. This widget then gets added to a grid layout. All of this is fine and good. My problem is that this is setting the entire widgets width including the rasterview's labels and color map area.

    So I haven't found a way to calculate how much space is needed so my column of data is a set size. For example, both the following images have the same geometry and min width in the same grid layout.
    This one is the way I want it
    notOverWritten.jpg

    This one needs more space to show what I want. Notice that the labels and the color bar overlap each other and there is no room for the column of data. How do I set the plot width without the labels and color map bar or how do I work the numbers backwards to determine the space required?
    overwritting.jpg

    Thanks in advance for any help,
    Buffy

  4. #4
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QwtMatrixRasterData - setting a fixed column width

    Quote Originally Posted by Buffy View Post
    ... how do I work the numbers backwards to determine the space required?
    Qt Code:
    1. virtual QSize YourPlot::sizeHint() const
    2. {
    3. const int dim = 10000; // something large
    4. plotLayout()->activate( this, QRectF( 0, 0, dim, dim ) );
    5.  
    6. const int canvasWidth = ...; // this is the number of pixels you want to have for your canvas
    7. int w = canvasWidth + dim - plotLayout()->canvasRect().width();
    8.  
    9. plotLayout()->invalidate();
    10.  
    11. return QSize( w, QwtPlot::sizeHint().height() );
    12. }
    To copy to clipboard, switch view to plain text mode 

    The idea is to calculate the layout with some large rectangle. As the canvas gets all the additional space you can easily calculate the fixed parts by subtracting the calculated canvas width. Then add the width you need.

    Uwe

Similar Threads

  1. Replies: 9
    Last Post: 13th June 2012, 15:42
  2. Fixed column width in QAbstractTableModel
    By hailflex in forum Newbie
    Replies: 1
    Last Post: 11th December 2009, 06:58
  3. QToolBox width fixed to maximum content width
    By ghorwin in forum Qt Programming
    Replies: 0
    Last Post: 10th July 2009, 09:58
  4. QWidget with fixed width height ratio
    By Lodorot in forum Qt Programming
    Replies: 1
    Last Post: 26th May 2009, 08:49
  5. Fixed Column in QTreeview
    By ormonde in forum Qt Programming
    Replies: 3
    Last Post: 12th May 2008, 07:49

Tags for this Thread

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.