Results 1 to 20 of 46

Thread: Qpainter function on a QFrame problem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qpainter function on a QFrame problem

    Have you seen this thread?

    http://www.qtcentre.org/forum/f-qt-d...bel-11504.html

    Especially take a look at how the line is drawn depending on the size of the widget.

  2. The following user says thank you to wysota for this useful post:

    impeteperry (27th January 2008)

  3. #2
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Qpainter function on a QFrame problem

    Thanks Mysota It was a great help.My big problem I forgot the line under the "public;" when defining the class. What ever you do, don't get old (I'm 81).

    Now all I have to do is figure out how to set the size of the frame, but I"m going to bed it's 12:30.

    Thanks again.

  4. #3
    Join Date
    Aug 2007
    Location
    Gorakhpur, India
    Posts
    254
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Qpainter function on a QFrame problem

    Thanks Mysota It was a great help.My big problem
    Please mention the name correctly as Wysota, Qt Guru.
    Last edited by wysota; 28th January 2008 at 10:19. Reason: Please use proper tags - [quote] instead of [code] :P
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

  5. #4
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Qpainter function on a QFrame problem

    Wysots, Qi Guru, I'm sorry about the name. It was late and I don't see to well.
    I have made some progress. I can draw some lines, so I am back at setting up my scaling functions.
    I do have a question. In the distant past I wrote to a "pixmap". is there any advantage to that now with the paintEvent functionallity?
    Thanks

  6. #5
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Qpainter function on a QFrame problem

    Hi
    I now have my painter working on my laptop whereI compiled the program.
    It also runs on my desk computer as long as I don't re-compile it there. If I re-compile the same source code there it locks up the computer on the first "p.drawText" command. I have single stepped the program on both computers. Everything is the same. There is no problem with the "p.drawLine" command. If I option out the single p.drawText(x, y, "text"); line 16, the program runs fine.
    Qt Code:
    1. p.drawLine ( xs, ys, xe, ye );
    2. /// start of labeling.
    3. if ( tempList[4] == "true" )
    4. {
    5. xc = ( xs + xe ) / 2;
    6. yc = ( ys + ye ) / 2;
    7. if ( xs == xe ) angle = pi/2.0;
    8. else if ( ys == ye ) angle = 0.0;
    9. else angle = atan((double)(ye - ys) / (double)(xe - xs));
    10. angle = ( angle * 180.0 ) / pi;
    11. p.save();
    12. p.translate ( xc, yc );
    13. p.rotate ( angle );
    14. p.scale ( 1, -1 );
    15. k = "S" + h.setNum ( n + 1 );
    16. p.drawText ( 0, 0, k );
    17. p.restore();
    18. }
    To copy to clipboard, switch view to plain text mode 
    I am using the same Kubuntu 7.10 on each computer.
    I am sorry to be such a pest.
    Thanks for help.

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

    Default Re: Qpainter function on a QFrame problem

    What exactly is the widget supposed to display?

  8. #7
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Qpainter function on a QFrame problem

    I have a bunch of lines and i label them with their number. the text I want to display is "S1" See attachment. These are "Grid" lines are used for locating building columns and other elements.
    Except for the screen size the data is identical on the two computers. The lines draw correctly so the "viewWindow" and "viewPort" are set correctly. If I take the compiled program from the second machine, it runes fine on the firsrt machine.

    In essense, the program compiled on the first computer runs fine on both computers
    The program compiled on the second computer locks it up when run, but runs fine on the first computer.
    Attached Images Attached Images

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

    Default Re: Qpainter function on a QFrame problem

    Why don't you use QGraphicsView to make the visualization?

  10. #9
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Qpainter function on a QFrame problem

    QGraphicsView was add in Qt4.2. I was unaware of its existance
    Thanks, I will take a look at it.

  11. #10
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Qpainter function on a QFrame problem

    I took a quick look at your QGraphicView and found
    By default, the items are drawn onto the viewport by using a regular QPainter, and using default render hints.
    What would be the advantage using this when I already have the geometry and am already using the "painter" to draw items onto the "viewPort"?

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

    Default Re: Qpainter function on a QFrame problem

    Ease of handling. I don't say you should take that approach, but that if you have problems with one mechanism, try using another.

  13. The following user says thank you to wysota for this useful post:

    impeteperry (1st February 2008)

  14. #12
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Qpainter function on a QFrame problem

    Well said.
    I am still confused why a program compiled on one computer won't run on that computer, but will run on another one, I may try reinstalling Qt. but for now I will continue with the development of my program.
    Thanks for your help and suggestions. Don't you ever sleep?
    pete

  15. #13
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Qpainter function on a QFrame problem

    I re-installed Qt-4 and all works now. Onward ever onword.
    Thank you for your patience
    pete

  16. #14
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Qpainter function on a QFrame problem

    Hi, on the same subject.
    My drawing is fine, but now I want to open a frame with a textEdit in it on top of the drawing with out the drawing showing through (help info) and when the frame is closed the drawinig is back. I thought Qt-4's "double buffering" took care of this.
    Thanks
    Attached Images Attached Images
    Last edited by impeteperry; 12th February 2008 at 05:42.

  17. #15
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Qpainter function on a QFrame problem

    I'm back with another very confusing problem.
    I have 2 versions of the same program. Call them A & B. I use
    Qt Code:
    1. void MyDrawingFrame::slotSetPaintItems ( QStringList list )
    2. {
    3. int n;
    4. for(n = 0; n < list.count(); ++n )
    5. {
    6. tempList = list[n].split("|"); /// split the list into types of stringLists
    7. k = tempList[0]; /// get the type of element to draw
    8. if(k == "erase") clearWindow = "erase";
    9. else
    10. {
    11. tempList.removeFirst(); /// remove the element with the code
    12. clearWindow = "false";
    13. if(k=="supports")
    14. paintSupportLines=tempList;
    15. else if(k=="columns")
    16. paintColumns=tempList;
    17. else if(k=="help")
    18. paintDrawHelpWindow=tempList;
    19. else if(k=="erase")
    20. clearWindow="true";
    21. }
    22. }
    23. emit getDrawingFrameSize (&W,&H);
    24. k = actionList.last();
    25. tempList = k.split(",");
    26. if(tempList[1] == "4") setGeometry (10,10,W ,H);
    27. else setGeometry (10,10,0,0);
    28. update();
    29. }
    To copy to clipboard, switch view to plain text mode 
    for both versions and as near as I can tell the same data. There are two stages. The first just displays the "support lines" and the second displays both the "support lines" and the "colums".(see attachments from version B) Version A is fine for just the support lines, but when trying to display both the program crashes with the following statement which I don't understand at all.
    { Q_ASSERT_X(i >= 0 && i < p.size(), "QList<T>:perator[]", "index out of range");
    detach(); return reinterpret_cast<Node *>(p.at(i))->t(); }
    I have replaced the "update" with "redraw" but same problem. I don't think the problem is in the "paint event" itself,

    As usual I would appreciate any help you can give me.
    thanks.
    Attached Images Attached Images

Similar Threads

  1. QPSQL driver in windows
    By brevleq in forum Installation and Deployment
    Replies: 31
    Last Post: 14th December 2007, 12:57
  2. how to add static library into qmake
    By Namrata in forum Qt Tools
    Replies: 1
    Last Post: 20th November 2007, 17:33
  3. Problem emitting signal from a static function
    By Valheru in forum Qt Programming
    Replies: 21
    Last Post: 12th June 2007, 14:48
  4. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  5. use qpsql
    By raphaelf in forum Installation and Deployment
    Replies: 34
    Last Post: 22nd August 2006, 12:52

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.