Ease of handling. I don't say you should take that approach, but that if you have problems with one mechanism, try using another.
Ease of handling. I don't say you should take that approach, but that if you have problems with one mechanism, try using another.
impeteperry (1st February 2008)
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
I re-installed Qt-4 and all works now. Onward ever onword.
Thank you for your patience
pete
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
Last edited by impeteperry; 12th February 2008 at 05:42.
It's a matter of passing the QTextEdit widget a proper parent.
J-P Nurmi
Thanks, it came to me last night what I was doing wrong.
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.
The code below is for the HelpFunction class. Below the horizontal line controls the toggle function.Qt Code:
///----------------------------------------------------------------------------Pb1 void BaseForm::slotPb1() { emit activate(); paintList.append("help"); emit displayErectionDrawing(paintList, helpFlag); }To copy to clipboard, switch view to plain text mode
Line 23 displays the status of the toggle so I can tell if the "F1" keystroke was received.
There are several problemsQt Code:
{ frameH->setAutoFillBackground ( true ); teHBox->setAutoFillBackground(true); teHBox->setReadOnly ( true ); } void HelpFunction::slotActivate() { emit getDrawingFrameSize ( &W, &H ); emit getTextListItem(2, &k); frameH->setGeometry ( W - 350, H - 420, 350, 430 ); teHBox->setGeometry ( 10, 10, 330, 410 ); teHBox->setPlainText ( k ); emit showHelpFrame(frameH); //-------------------------------------------------------------------------- if(helpFlag == false) k = "false"; else k = "true"; emit setMessageBox("help 15 helpFlag = " + k); if(helpFlag == true) helpFlag = false; else if(helpFlag == false) helpFlag = true; else helpFlag = true; }To copy to clipboard, switch view to plain text mode
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.
[/CODE]Qt Code:
connect ( Pb1, SIGNAL ( clicked() ), this, SLOT ( slotPb1() ) ); ///--------------------------------------------------------Function Keys connect ( this, SIGNAL ( fk1clicked() ), this, SLOT ( slotPb1() ) );To copy to clipboard, switch view to plain text modeThank you very muchQt Code:
{ int n; QString h; n = k->key(); h = h.setNum ( n ); if ( k->key() == 16777264 && Pb1->text() != "-" ) emit fk1clicked(); if ( k->key() == 16777265 && Pb2->text() != "-" ) emit fk2clicked();To copy to clipboard, switch view to plain text mode
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
You see... the problem is we are not seeing your problemI 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.
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
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.
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.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 .
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...
impeteperry (31st March 2008)
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 20:25.
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.
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: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"?
Qt Code:
class MyClass: public ... { Q_OBJECT public: //... public slots: if(txt==m_helpText) return; m_helpText = txt; update(); } protected: void paintEvent(...){ //... if(!m_helpText.isEmpty()){ p.save(); //... p.drawRect(...); p.drawText(...); p.restore(); } } };To copy to clipboard, switch view to plain text mode
Actually I'd use QCanvas or QGraphicsView...
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).
I'm back with another very confusing problem.
I have 2 versions of the same program. Call them A & B. I usefor 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.Qt Code:
{ int n; for(n = 0; n < list.count(); ++n ) { tempList = list[n].split("|"); /// split the list into types of stringLists k = tempList[0]; /// get the type of element to draw if(k == "erase") clearWindow = "erase"; else { tempList.removeFirst(); /// remove the element with the code clearWindow = "false"; if(k=="supports") paintSupportLines=tempList; else if(k=="columns") paintColumns=tempList; else if(k=="help") paintDrawHelpWindow=tempList; else if(k=="erase") clearWindow="true"; } } emit getDrawingFrameSize (&W,&H); k = actionList.last(); tempList = k.split(","); if(tempList[1] == "4") setGeometry (10,10,W ,H); else setGeometry (10,10,0,0); update(); }To copy to clipboard, switch view to plain text modeI have replaced the "update" with "redraw" but same problem. I don't think the problem is in the "paint event" itself,{ Q_ASSERT_X(i >= 0 && i < p.size(), "QList<T>:perator[]", "index out of range");
detach(); return reinterpret_cast<Node *>(p.at(i))->t(); }
As usual I would appreciate any help you can give me.
thanks.
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?
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
Last edited by impeteperry; 10th September 2008 at 06:36.
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 really suggest you reconsider using GV. It's perfect for your usecase.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.
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.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
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.
Hmm... honestly I don't see anything 3D in the second image you attached to the last post.
Bookmarks