Results 1 to 20 of 35

Thread: Painting lines

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Posts
    87
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    6
    Thanked 1 Time in 1 Post

    Default Re: Painting lines

    hey there i tried using the QVector to make my struct into an array but the program crashes when i try to run it. it compiles ok but there seems to be a problem with the way i am referencing the QVector...heres my code below:

    Qt Code:
    1. links[0].n2 = QInputDialog::getInteger(this, tr("QInputDialog::getInteger()"),
    2. tr("enter second node to link:"), 25, 0, 100, 1, &ok);
    3.  
    4. if(ok)
    5. integerLabel->setText(tr("%1").arg(links[0].n2));
    To copy to clipboard, switch view to plain text mode 

    any help would be much appreciated again

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts

    Default Re: Painting lines

    void QVector::append ( const T & value )
    Inserts value at the end of the vector.

  3. #3
    Join Date
    Feb 2006
    Posts
    87
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    6
    Thanked 1 Time in 1 Post

    Default Re: Painting lines

    hey there i tried .append() but it still didnt work. i get an error saying:

    "not enough contextual info to determine type"
    i tried it with the following piece of code:

    Qt Code:
    1. links.capacity.append(topology[n1][n2]);
    To copy to clipboard, switch view to plain text mode 

    what am i doing wrong?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: Painting lines

    Quote Originally Posted by therealjag
    links.capacity.append(topology[n1][n2]);
    What types do the links and links.capacity have?

  5. #5
    Join Date
    Feb 2006
    Posts
    87
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    6
    Thanked 1 Time in 1 Post

    Default Re: Painting lines

    links is just my struct Link and it contains the integer which is called capacity..
    my struct is shown below:

    Qt Code:
    1. struct Link{
    2.  
    3. int n1;
    4. int n2;
    5. int capacity;
    6. }
    To copy to clipboard, switch view to plain text mode 
    the 2-d array is just an integer as well

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: Painting lines

    int doesn't have an append() method. You probably wanted to invoke that method on some other object.

  7. #7
    Join Date
    Feb 2006
    Posts
    87
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    6
    Thanked 1 Time in 1 Post

    Default Re: Painting lines

    int doesn't have an append() method.
    ok, so how do i add that number from topology[n1][n2] to link.capacity? i also tried insert() with my code instead of append and it still didnt work??

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: Painting lines

    Quote Originally Posted by therealjag
    ok, so how do i add that number from topology[n1][n2] to link.capacity? i also tried insert() with my code instead of append and it still didnt work??
    What do you mean by "add"? capacity in an integer and it can hold only one value. You should create a list or vector and add values to it.

  9. #9
    Join Date
    Feb 2006
    Posts
    87
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    6
    Thanked 1 Time in 1 Post

    Default Re: Painting lines

    What do you mean by "add"? capacity in an integer and it can hold only one value. You should create a list or vector and add values to it.
    oh sorry i was a bit unclear i just want the value at capacity[n1][n2] to be equal to one of the instances in my vector 'links' and i want it to be stored into link.capacity?

Similar Threads

  1. how do i know if two lines intersect?
    By Vincenzo in forum Newbie
    Replies: 4
    Last Post: 7th November 2008, 14:23
  2. I want to get lines of text
    By newplayer in forum Qt Programming
    Replies: 11
    Last Post: 29th July 2008, 09:03
  3. Display QLabel in two lines
    By arunvv in forum Newbie
    Replies: 1
    Last Post: 8th February 2008, 05:25
  4. Slow painting in QGraphicsView
    By JonathanForQT4 in forum Qt Programming
    Replies: 12
    Last Post: 16th July 2007, 09:54
  5. How to draw lines with the right width?
    By albanelporto in forum Qt Programming
    Replies: 3
    Last Post: 22nd November 2006, 11:51

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.