Page 2 of 3 FirstFirst 123 LastLast
Results 21 to 40 of 46

Thread: Qpainter function on a QFrame problem

  1. #21
    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

  2. #22
    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

  3. #23
    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 06:42.

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

  5. #25
    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.

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

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

  8. #28
    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: 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.

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

  10. #30
    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: Qpainter function on a QFrame problem

    Quote Originally Posted by impeteperry View Post
    Thanks for your suggestion, but I'm afraid you are missing the point of my program.
    I'm not. You're missing the point of your problem. You have problems with drawing, not with input events. That's why I say to make your widget draw in a predictable, reproducable and desirable way and only then add value to it, not the other way round.

    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 .
    Please don't insult us. You know nothing of us or problems we are dealing with. At the same time you are asking for help with your problem, not the other way round.

    As for one of your questions - switching to Qt4 is a good idea in general, especially that it will probably force or encourage you to do it the right way - using QGraphicsView and not drawing directly inside a frame. You should have used QCanvas...

    Your code cries: refactor me! But what do I know.... I'm not dealing with problems complex enough to know anything about yours...

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

    impeteperry (31st March 2008)

  12. #31
    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

    Sir, I am not insulting you, Qt or anybody else. I appreciate your effort to help me. so enough of that!

    I thought the forum was for help on my problems using your product rather then the other way around.

    The use of the "function/accelerator keys" for program control rather then the mouse is part and parcel of what I am trying to develop, right or wrong.

    My problem is "I can show a "Help widget" on a painter by pressing a function key, but I can't delete it by pressing a function key". My Question is "what code to I need to add to my "help Widget to correct this problem"?

    I see that Qt 4 no longer lists QCanvas, however I shall go back to square one, look at QGraphicView and see if I an do in Qt what I did in DOS.

    Again, I am sorry if I offended you in any way, sometimes I don't express myself to well.

    Thanks

    I went to "examples" for QGraphicview and found collindingmice. Oh what a delightful examole!!!
    I see there is layering there. Let you know how I make out.

    Thanks again,
    Last edited by impeteperry; 31st March 2008 at 21:25.

  13. #32
    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: Qpainter function on a QFrame problem

    Quote Originally Posted by impeteperry View Post
    The use of the "function/accelerator keys" for program control rather then the mouse is part and parcel of what I am trying to develop, right or wrong.
    But that's not the issue here. If you have other things working, adding accelerators is trivial. If something doesn't work, it means the problem is elsewhere.

    My problem is "I can show a "Help widget" on a painter by pressing a function key, but I can't delete it by pressing a function key". My Question is "what code to I need to add to my "help Widget to correct this problem"?
    You need to implement a paint event correctly, so that it takes into consideration the help widget. I'd add a property holding the help text to show and when the text is empty, hide the help and otherwise render the text. Something like:

    Qt Code:
    1. class MyClass: public ... {
    2. Q_OBJECT
    3. Q_PROPERTY(QString helpText READ helpText WRITE setHelpText)
    4. public:
    5. //...
    6. const QString &helpText() const { return m_helpText; }
    7. public slots:
    8. void setHelpText(const QString &txt) {
    9. if(txt==m_helpText) return;
    10. m_helpText = txt;
    11. update();
    12. }
    13. void clearHelpText() { setHelpText(QString::null); }
    14. protected:
    15. void paintEvent(...){
    16. QPainter p(this);
    17. //...
    18. if(!m_helpText.isEmpty()){
    19. p.save();
    20. //...
    21. p.drawRect(...);
    22. p.drawText(...);
    23. p.restore();
    24. }
    25. }
    26. };
    To copy to clipboard, switch view to plain text mode 

    Actually I'd use QCanvas or QGraphicsView...

  14. #33
    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

    Taking your advice, I am looking at QGraphicView-scene. As I said, I would start from scratch. This looks promising.

    Being a bit mentally retarded at 82 and in need of an eye operation it will take a bit of time.

    I am a little leery of QCanvas as it is no longer listed in the Qt documentation under "all classes". (I did some stuff with it under Qt 3).

  15. #34
    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: Qpainter function on a QFrame problem

    QCanvas and QGraphicsView are very similar. There's even an article written by Andreas on QQ on porting QCanvas applications to Graphics View.

  16. #35
    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 confused. If QCanvas is not listed Qt4, do you mean go back to Qt3 or that If I worked in QCanvas in Qt3, I should not have any problem with QGraphicsview in Qt 4?

  17. #36
    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: Qpainter function on a QFrame problem

    I mean use Qt4 and GV.

  18. #37
    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

  19. #38
    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: 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?

  20. #39
    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 07:36.

  21. #40
    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: 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.

Similar Threads

  1. QPSQL driver in windows
    By brevleq in forum Installation and Deployment
    Replies: 31
    Last Post: 14th December 2007, 13:57
  2. how to add static library into qmake
    By Namrata in forum Qt Tools
    Replies: 1
    Last Post: 20th November 2007, 18:33
  3. Problem emitting signal from a static function
    By Valheru in forum Qt Programming
    Replies: 21
    Last Post: 12th June 2007, 15:48
  4. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 07:13
  5. use qpsql
    By raphaelf in forum Installation and Deployment
    Replies: 34
    Last Post: 22nd August 2006, 13: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.