lol. but theres only you who reply me... lol
eh.. how do i place the position and adjust the length and width of the lineedit ontop of the painter widget?
Printable View
lol. but theres only you who reply me... lol
eh.. how do i place the position and adjust the length and width of the lineedit ontop of the painter widget?
lineedit->move(), linedit->resize()
and the "gurus" are in different timezones so just wait a while...
now dont ask anymore questions... read the tutorial and come back after two days..
Read about the layout system of Qt (QBoxLayout, QGridLayout). Don't position them fix!
and how many weeks did you have for the project? maybe you should start doing it earlier :]
And I don't see why Qt is hard? Because it's C++ library? Then it means that C++ is hard for you (for me it is not so hard). Qt has a really good documentation, a lot of examples and everything. I have my assistant open almost everytime I code with Qt just to check the right metods, signals and such things.
And how many years are you studying? I had different programming languages on my studies, and I use C++ but I think that general idea is similar in C# and Java so if you know C# then doing something in C++ shouldn't be a big problem. And Qt is just a bunch of C++ classes (plus some tools).
LOL yellow bubble thread -_-!
i left with 3 more weeks. i only had 12 weeks to do this. like i said, i had already done much changes to my project already. left with this name thing.Quote:
and how many weeks did you have for the project? maybe you should start doing it earlier :]
hmm. i dun know why, but it just look abit hard to understand, even with the assistant, haha. like i say again, i am totally new to this Qt open source.Quote:
And I don't see why Qt is hard? Because it's C++ library? Then it means that C++ is hard for you (for me it is not so hard). Qt has a really good documentation, a lot of examples and everything. I have my assistant open almost everytime I code with Qt just to check the right metods, signals and such things.
3 years of engineering, this is my final year. hehe. hmm. perhaps i don understand and dun know how to apply the classes of the Qt source i guess. and for this project. there is alot of .cpp in it. maybe that is why it making me more hard to cope with. as whatever i learnt in my 2 years, i only counter with 1 .cpp, all the programming is done in that 1 .cpp including the declaration.Quote:
And how many years are you studying? I had different programming languages on my studies, and I use C++ but I think that general idea is similar in C# and Java so if you know C# then doing something in C++ shouldn't be a big problem. And Qt is just a bunch of C++ classes (plus some tools).
nvm. i will work harder, its an exposure for me doing this final year project. i love programming. haha.
you have to pass the parent to lineedit
new QLineEdit(this);
you have to make the lineEdit the child of the widget you want to show it on..
so pass the parent as the pointer of that widget..
and you havent fully read the tutorial yet.
i really dont know how man. below is the void i wanan add the lineedit into.
the lineedit command is at the end of this void.
Code:
{ pixmap2.fill(Qt::white); QPixmap pix; QString id; Q_UNUSED(option); QSettings settings; nodeAlertTemp = settings.value("NodeAlertTemp", 10).toDouble(); if (nodeData.addr!=0){ if(nodeData.fadeNumber>5&&nodeData.deletedNode!=0) { nodeData.fadeNumber-=fade_speed; if (nodeData.fadeNumber<=5){ nodeData.fadeNumber=0; nodeData.deletedNode=1; index_number=0; } } if(nodeData.fadeNumber<255&&nodeData.newNode!=0) { nodeData.fadeNumber+=fade_speed; if (nodeData.fadeNumber>=255) { nodeData.fadeNumber=255; nodeData.newNode=0; //current_updateData(index_number); index_number=0; } } } // Draw the grey shadow for a 3d effect. painter->setPen(Qt::NoPen); painter->drawEllipse(-45, -45, 100, 100); // Set gradient and color of the node if (nodeData.addr==0&&updated == true) { // Mouse click on node or an update of node data~ gradient.setCenter(3, 3); gradient.setFocalPoint(3, 3); gradient.setColorAt(1, nodeColor.light(120)); gradient.setColorAt(.5, nodeColorDark.light(120)); gradient.setColorAt(0, nodeColorDark.light(120)); updated = false; painter->setBrush(gradient); } else if (nodeData.addr==0&&updated == false) { gradient.setColorAt(0, nodeColor.light(150)); gradient.setColorAt(1, nodeColorDark); painter->setBrush(gradient); } // end devices if (nodeData.addr!=0&&updated == true) { // Mouse click on node or an update of node data~ gradient.setCenter(3, 3); gradient.setFocalPoint(3, 3); gradient.setColorAt(1, nodeColor); gradient.setColorAt(.5, nodeColor); gradient.setColorAt(0, nodeColor); updated = false; painter->setBrush(gradient); } else if (nodeData.addr!=0&&updated == false) { gradient.setColorAt(0, nodeColor); gradient.setColorAt(.95, nodeColorDark); gradient.setColorAt(1, nodeColor); painter->setBrush(gradient); } // painter->setBrush(gradient); // Draw black circle around the node // Draw the node painter->drawEllipse(-50, -50, 100, 100); //x new text // White pen for text if (nodeData.addr==0) { } else { if(nodeData.re<100) { } else { } } QString qsTemp; QString qsTemp2; // Write RE if (nodeData.re>100) { rebyte=nodeData.re-100; } else { rebyte=nodeData.re; } if (rebyte>4&&nodeData.addr>0) { qsTemp.sprintf("%d Sec", rebyte);//rebyte painter->setFont(timeFont); painter->drawText(-50,+8,100,20,Qt::AlignCenter , qsTemp,0); } else if (nodeData.addr>0) { qsTemp.sprintf("%d Min", rebyte); painter->setFont(timeFont); painter->drawText(-50,+8,100,20,Qt::AlignCenter , qsTemp,0); } else if (nodeData.addr==0) { //qsTemp = timeStamp.toString("hh:mm:ss"); qsTemp = timeStamp.toString(Qt::LocalDate); //qsTemp.sprintf("TxCt: %d", cnt_rf);// for Jeff battery test only painter->setFont(timeFont); painter->drawText(-50,+5,100,20,Qt::AlignCenter , qsTemp,0); } // Write the battery voltage qsTemp.sprintf("%.1fV", nodeData.voltage); painter->setFont(battFont); painter->drawText(-50,+25,100,20,Qt::AlignCenter , qsTemp,0); // Set text in the node // Write the temperature if(celsius) { qsTemp.sprintf("%.1f°C", ((nodeData.temp-32.0)/1.8)); } else { qsTemp.sprintf("%.1f°F", nodeData.temp); } if (nodeData.addr==0) //node 0 { //xpainter->setFont(tempFont); painter->setFont(addrFont); painter->drawText(-50,-45,100,40,Qt::AlignCenter , qsTemp,0); } else { painter->setFont(timeFont); painter->drawText(-50,-48,100,40,Qt::AlignCenter , qsTemp,0); } if (nodeData.addr==0) //node 0 { // Write node number //qsTemp.sprintf("Node: %d", nodeData.addr); qsTemp.sprintf("Access Point"); //xpainter->setFont(addrFont); painter->setFont(timeFont); painter->drawText(-50,-15,100,20,Qt::AlignCenter , qsTemp,0); } else { // Write node number // end device details qsTemp.sprintf("End Device %d", nodeData.addr); //xpainter->setFont(addrFont); painter->setFont(timeFont); painter->drawText(-50,-22,100,20,Qt::AlignCenter , qsTemp,0); //Write signal strength in ED node if (nodeData.strength > 21) { qsTemp.sprintf("Strong", nodeData.strength); painter->setFont(strengthFont); painter->drawText(-50,-8,100,20,Qt::AlignCenter , qsTemp,0); } else if (nodeData.strength > 15) { qsTemp.sprintf("Medium", nodeData.strength); painter->setFont(strengthFont); painter->drawText(-50,-8,100,20,Qt::AlignCenter , qsTemp,0); } else { qsTemp.sprintf("Weak", nodeData.strength); painter->setFont(strengthFont); painter->drawText(-50,-8,100,20,Qt::AlignCenter , qsTemp,0); } //temperture alert, if(nodeData.temp > (nodeAlertTemp*9)/5+32.0) { painter->setPen(Qt::NoPen); painter->drawEllipse(-45, -45, 100, 100); gradient.setCenter(3, 3); gradient.setFocalPoint(3, 3); gradient.setColorAt(1, nodeAlertColor); gradient.setColorAt(.5, nodeAlertColorDark); gradient.setColorAt(0, nodeAlertColorDark); painter->setBrush(gradient); painter->drawEllipse(-50, -50, 100, 100); if(celsius) { qsTemp.sprintf("ALERT!\n\ End Device %d\n\ %.1f°C\n\ ", nodeData.addr, ((nodeData.temp-32.0)/1.8)); painter->setFont(timeFont); painter->drawText(-50,-50,100,100,Qt::AlignCenter , qsTemp,0); } else { qsTemp.sprintf("ALERT!\n\ End Device %d\n\ %.1f°F\n\ ", nodeData.addr, nodeData.temp); painter->setFont(timeFont); painter->drawText(-50,-50,100,100,Qt::AlignCenter , qsTemp,0); } } painter->drawRect(-43,-20,85,15);
so your are creating a lineEdit inside the paint method which would be called thousands of time per second... so every time you will be creating the lineEdit and creating a memory leak. The line edit should be created once in the main widget on which the painter is painting and use the pointer to the line edit in paint()
hello~ Mr.Death~~~
hello there...
make the line edit in constructor of you widget being painted.
you have a widget subclass on which you use the QPainter rite?
make lineedit a member of your qwidget subclass and new it in the constructor of that subclass.
take a look at the example programs that comes with Qt please please....
widget painting example..