Results 1 to 4 of 4

Thread: Arrays in QScript

  1. #1
    Join Date
    Mar 2015
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Arrays in QScript

    The following doesn't seem to work - please can someone tell me where I am gong wrong. (this is QScript.)
    Qt Code:
    1. var Styles =[];
    2. Styles[1] = {};
    3. Styles[1].font = New Font();
    4. Styles[1].font.family = "Arial"; //f1 is for left side
    To copy to clipboard, switch view to plain text mode 
    I am trying to create an array of font styles.

    Where can I find the syntax for new Font()? ideally iwould like to do something like
    Qt Code:
    1. Styles[1].font = New Font("Arial",12, true,false, false); //Font (style, pointsize, bold, italic, underline)
    To copy to clipboard, switch view to plain text mode 

    Any Advice greatly appreciated.

    Thanks

    Allan

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Arrays in QScript

    What is Font? To add an element to an Array you need to either push it explicitly or use empty brackets as the index operator to append the element. See JavaScript docs on Array.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Arrays in QScript

    Quote Originally Posted by tsrplatelayer View Post
    Where can I find the syntax for new Font()?
    Look for the constructor function in the code that you register for handling that type.

    Cheers,
    _

  4. #4
    Join Date
    Mar 2015
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Arrays in QScript

    Thankyou for your replies. let me explain. I inherited this compiled project, the guy that coded it is no longer with us. It includes a QScript 'module' which allows prnted output to be configured. Hiwever the work was poorly done and instead of a nice template this print mode requires raw coade to be modified in order to change that page layout. am trying to work it out and make a few changes.
    I had assumed that Font() was a livbrary function but from the commnet from wysota I must conclude it is not.

    I think I have managed to work out what it needed
    I created a function
    Qt Code:
    1. function buildstyle ( face, size, bd, it, bg, fg, h ) //face, size, bold, italic, backgroundColor, foregroundColor, row height
    2. {
    3. var ff = new Font (); //create the font
    4. ff.family = face;
    5. ff.pointSize = size;
    6. ff.bold = bd;
    7. ff.italic = it;
    8. this.bg = bg; //set the colours, height and font
    9. this.fg = fg;
    10. this.h = h;
    11. this.fnt = ff;
    12. }
    To copy to clipboard, switch view to plain text mode 

    Although I bet there is a tidier way.

    and then used it:
    Qt Code:
    1. var aStyles = [];
    2. aStyles[0] = new buildstyle ("Arial", 12, true, false, "#ffffff", "#000000", 10);
    3. aStyles[1] = new buildstyle ("Arial", 12, false, false, "#ffffff", "#000000", 10);
    4. aStyles[2] = new buildstyle ("Arial", 12, false, true, "#ffffff", "#000000", 10);
    5. aStyles[3] = new buildstyle ("Arial", 12, false, false, "#ffffff", "#000000", 10);
    6. aStyles[4] = new buildstyle ("Arial", 10, false, false, "#ffffff", "#000000", 0);
    7. aStyles[5] = new buildstyle ("Arial", 10, false, false, "#333333", "#ffffff", 7.5);
    8. aStyles[6] = new buildstyle ("Arial", 10, false, false, "#ffffff", "#000000", 7.5);
    9. aStyles[7] = new buildstyle ("Arial", 10, false, false, "#666666", "#ffffff", 7.5);
    10. aStyles[8] = new buildstyle ("Arial", 10, false, false, "#dddddd", "#000000", 15);
    To copy to clipboard, switch view to plain text mode 

    This seems to work

Similar Threads

  1. QScript design questions
    By ctgrund in forum Newbie
    Replies: 4
    Last Post: 24th March 2011, 12:27
  2. Can't get qScript to work
    By lni in forum Qt Programming
    Replies: 1
    Last Post: 18th September 2010, 22:49
  3. How to use QScript?
    By lni in forum Qt Programming
    Replies: 5
    Last Post: 2nd August 2010, 15:36
  4. QScript workbench in 4.3
    By jh in forum Qt Programming
    Replies: 3
    Last Post: 29th October 2009, 14:53
  5. QVariantList from QScript?
    By musla in forum Qt Programming
    Replies: 0
    Last Post: 29th June 2009, 11:22

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.