Page 1 of 2 12 LastLast
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
    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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 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?

  3. #3
    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.

  4. #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

    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"?

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 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.

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

    impeteperry (1st February 2008)

  7. #6
    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

  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 re-installed Qt-4 and all works now. Onward ever onword.
    Thank you for your patience
    pete

  9. #8
    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.

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

    Default Re: Qpainter function on a QFrame problem

    It's a matter of passing the QTextEdit widget a proper parent.
    J-P Nurmi

  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

    Thanks, it came to me last night what I was doing wrong.

  12. #11
    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 am still having problems which I have narrowed down to maybe a Qt problem.
    I want to "show" a "help" box on a "QPainter" drawinq. I want to "toggle" this "box" by means of the keyboard "F1" key.
    Line #4 in the following code activates a HelpFunction class to do this as has been suggested and line #5 does this in the painter function itself.
    The first thumbnail just shows the drawing. The second shows the HelpFunction class "help box" after pressing the "F1" key.. The third shows the "help box" when generate by the painter itself.
    Qt Code:
    1. ///----------------------------------------------------------------------------Pb1
    2. void BaseForm::slotPb1()
    3. {
    4. emit activate();
    5. paintList.append("help");
    6. emit displayErectionDrawing(paintList, helpFlag);
    7. }
    To copy to clipboard, switch view to plain text mode 
    The code below is for the HelpFunction class. Below the horizontal line controls the toggle function.
    Line 23 displays the status of the toggle so I can tell if the "F1" keystroke was received.
    Qt Code:
    1. HelpFunction::HelpFunction(QWidget *parent) : QWidget(parent)
    2. {
    3. frameH = new QFrame();
    4. frameH->setAutoFillBackground ( true );
    5. frameH->setFrameShape ( QFrame::Box );
    6. frameH->setPalette ( QColor ( 200, 200, 200 ) );
    7. teHBox = new QTextEdit ( frameH );
    8. teHBox->setAutoFillBackground(true);
    9. teHBox->setPalette(QColor ( 210, 255, 255 ));
    10. teHBox->setReadOnly ( true );
    11. }
    12. void HelpFunction::slotActivate()
    13. {
    14. emit getDrawingFrameSize ( &W, &H );
    15. emit getTextListItem(2, &k);
    16. frameH->setGeometry ( W - 350, H - 420, 350, 430 );
    17. teHBox->setGeometry ( 10, 10, 330, 410 );
    18. teHBox->setPlainText ( k );
    19. emit showHelpFrame(frameH);
    20. //--------------------------------------------------------------------------
    21. if(helpFlag == false) k = "false";
    22. else k = "true";
    23. emit setMessageBox("help 15 helpFlag = " + k);
    24. if(helpFlag == true) helpFlag = false;
    25. else if(helpFlag == false) helpFlag = true;
    26. else helpFlag = true;
    27. }
    To copy to clipboard, switch view to plain text mode 
    There are several problems
    1. the first time the "F1" key was pressed, the HelpFunction "help box" was displayed as shown in the second thumbnail.
    2. After that, pressing the "F1" key had no effect.
    3. Clicking anywhere on the screen with the left mouse button closed the HelpFunction "help box" and left the "painter" help box displayed.
    4. Now the "F1" key toggled the "painter" help box.
    5, If I changed line #3 of the HelpFunction class to "frameH = new QFrame(this);", the toggle worked fine for the "painter" box thumbnail #2.
    6. CONCLUSION: When the "Help Function" box was displayed, the "F1" key was DEACTIVATED.

    If we get problem #6 corrected, I would much prefer the "Box" to look like the "painter" box, but with scroll bars and the functionality of the QTextEdit widget.
    If I am doing somthing wrong, I am including the pb1 and fk1clicked items which have worked flawlessly up to now.
    Qt Code:
    1. connect ( Pb1, SIGNAL ( clicked() ), this, SLOT ( slotPb1() ) );
    2. ///--------------------------------------------------------Function Keys
    3. connect ( this, SIGNAL ( fk1clicked() ), this, SLOT ( slotPb1() ) );
    To copy to clipboard, switch view to plain text mode 
    [/CODE]
    Qt Code:
    1. void BaseForm::keyPressEvent ( QKeyEvent *k )
    2. {
    3. int n;
    4. n = k->key();
    5. h = h.setNum ( n );
    6. if ( k->key() == 16777264 && Pb1->text() != "-" ) emit fk1clicked();
    7. if ( k->key() == 16777265 && Pb2->text() != "-" ) emit fk2clicked();
    To copy to clipboard, switch view to plain text mode 
    Thank you very much
    Attached Images Attached Images

  13. #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

    Ok, I don't blame you all if you are fed up with me, but please give me a answer

    Can I do what I want to in Qt4?

    Thanks

  14. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 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

    You see... the problem is we are not seeing your problem I suggest you forget about F keys and all that stuff and focus on implementing a widget with properties that allow you to modify the behaviour of the widget. When you have that done, start thinking about function keys.

  15. #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

    Thanks for your suggestion, but I'm afraid you are missing the point of my program.
    I am an engineer and innovator in the building industry. I have had 2 growing problems with the computer industry over the past 35 years. The complexity of the user interface (look at Blender) and the CAD programs in principle

    This may not be the proper forum for a discussion of this type. Please let me know if it is oK or suggest another Qt forum .

    Thasks
    pete perry

  16. #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

  17. #16
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 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

    I'd say tempList has no items and so tempList[0] fails. Or it can have one value and tempList[1] fails.

    Could you explain what is preventing you from using Qt4 and QGraphicsView?

  18. #17
    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 am going back and check my data as I am sure that is where it must be as you suggest, but I would like to know about the "{ Q_ASSERT_X(i >= 0 && i < p.size(),...." message. can it help me find where and what is the problem is?.

    I looked at QGraphicsView, as you suggested earlier, but for some reason decided not to go there. I will however do so now and try to make a parallel program to the one I have now.

    What I am trying to do as a structural engineer is write a parametric driven program to replace the current CAD programs used in the industry and one that someone can learn to use in a day or two by going back to a modified command line operation similar to one I had written in pre-dos days. I do not have any time restraints, but a need to get it right.

    I took a quick look at "graphicsview" and noted it was a 2D program and the program i am trying to re-write was a 3D rendered structure
    Thanks for you indulgence
    Attached Images Attached Images
    Last edited by impeteperry; 10th September 2008 at 06:36.

  19. #18
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 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

    Quote Originally Posted by impeteperry View Post
    I am going back and check my data as I am sure that is where it must be as you suggest, but I would like to know about the "{ Q_ASSERT_X(i >= 0 && i < p.size(),...." message. can it help me find where and what is the problem is?.
    Not really. But a backtrace from a debugger will and I suggest you use one here. There is no point in guessing if the application itself can tell you what is wrong.

    I looked at QGraphicsView, as you suggested earlier, but for some reason decided not to go there. I will however do so now and try to make a parallel program to the one I have now.
    I really suggest you reconsider using GV. It's perfect for your usecase.

    I took a quick look at "graphicsview" and noted it was a 2D program and the program i am trying to re-write was a 3D rendered structure
    But you are rendering it on a 2D canvas, so everything is ok. If you want to have real 3D, consider using OpenGL with one of the viewer frameworks available for Qt.

  20. #19
    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
    I am using opengl.

    There are 2 parts to the program.
    1. developing a library of concrete elements (columns, beams, plank, connection hardware etc.) using opengl.

    2. defining where they go.

    This in a replacement for conventional CAD! which is prone for errors resulting from a multiplicity of input points for a given item. (floor plan, excavations, wall sections and details);

    I layout a set of grids( support lines)
    select a level (1st, 2nd, 3rd etc floor, )
    place columns from the column library and locate them on grid intersections
    place beams from the beam library and locate them by their supporting columns
    place plank from the plank library and locate them by their supporting beams

    now, if a grid line is moved, the associated columns move, the beam location and spans change, the plank location and spans change.
    Now is a change levels, the column length changes etc.

    this is all done automatically. Sort of like a "solid modeler" which I had tried.

    Sorry to be so verbose, and I thank you for you patients.
    Attached Images Attached Images

  21. #20
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 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

    Hmm... honestly I don't see anything 3D in the second image you attached to the last post.

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.