PDA

View Full Version : linking of combox with lineEdit.



Devoraz
24th July 2009, 04:23
Hi. from the image. i would like to link the Combox with the lineEdit. as in i select End device 1, only the things in end device 1 would be change to whatever i type in the lineEdit. can anyone give me some example of code about doing it?

nish
24th July 2009, 04:40
connect the singnal of combobox activated() to some slot in your dialog and play with lineedit

Devoraz
24th July 2009, 04:43
i know the connect part. but how about the play part?

nish
24th July 2009, 04:50
but how about the play part?

you have not explained very well what is the play part?

only the things in end device 1 would be change to whatever i type in the lineEdit.
what the heck anybody can understand by this?

Devoraz
24th July 2009, 04:53
i have attach an image what..

Devoraz
24th July 2009, 04:56
connect the singnal of combobox activated() to some slot in your dialog and play with lineedit

you said play with lineedit.


anyway. izzit possible when the combox is selected and the words in the lineedit is type. then i use qsTemp.sprintf to display the word in my GUI?

nish
24th July 2009, 04:57
why cant you rephrase your question?
do you whant to change the text in combobox to whatever u type in lineedit?


EDIT..

i still cant understat what is qTemp?

Devoraz
24th July 2009, 05:07
do you whant to change the text in combobox to whatever u type in lineedit?


nope. okay i roughly explain what i am doing and what i want. first for the image there is a yellow node. they will be 8 of them. so my combobox i already set it to 8 choice. from "End Device 1 to 8"

so now lets say when i select End device 1 on my combobox, and a type a certain word in the lineEdit. when i press ok. the word in the line edit will appear on the yellow node.



i still cant understat what is qTemp?

nvm just know it as printf.

nish
24th July 2009, 05:23
do it like this..

//main
MyDialog dlg;

if(dlg.exe()==QDialog::Accepted)
{
int deviceId = dlg.getDeviceId();
QString word = dlg.getWord();
if(!word.isEmpty())
putWordInUse(word);
.....
...
}

//MyDialog
int MyDialog::getDeviceId()
{
return combobox->currentIndex()+1;//0+1=end device 1 ,1+1.....
}

int MyDialog::getWord()
{
return lineEdit->text();
}

do not forget to connect the ok button to accept() slot of QDialog

Devoraz
24th July 2009, 05:42
i dun think this will work with my current code. argh talking in forum is pretty hard man. i cant possible post my whole source code here.

do you have a msn or something? so i could end you my whole program. and u help me take a look?

nish
24th July 2009, 05:46
sorry man .. this is the best i can do...

Devoraz
24th July 2009, 06:41
oh man. i seriously need some help here. anybody?

Devoraz
24th July 2009, 08:06
no reply from anyone else?

faldzip
24th July 2009, 09:07
I think that it is hard to give you some example because we don't know what is that yellow node. Is it some widget or what? A picture? Diagram in some other application? There are some signals in QLineEdit which you can use (like textChanged() ) so you can connect them to your slots, where you can check the current combo box selection and change proper node (yellow or any other you want). But how would I know how to change that yellow node? Paint it with QPainter or what?

Lykurg
24th July 2009, 09:11
do you have a msn or something? so i could end you my whole program. and u help me take a look?

That's a bad idea, because then all other board members can't learn from your problem.


no reply from anyone else?

We live in different time zones, so sometimes we have to sleep;)


And as to your question: It's also not very clear to me what you want to achieve: Change the yellow bubble text on the fly while typing in the line edit, or after the dialog has closed?

For the first, emit a signal from the dialog whenever the text changes. catch that in your main window and manipulate the corresponding node.

Devoraz
24th July 2009, 09:48
And as to your question: It's also not very clear to me what you want to achieve: Change the yellow bubble text on the fly while typing in the line edit, or after the dialog has closed?
.

after closing the dialog. i would need to use case method with the combobox i think? as there are 8 choice to select.

Devoraz
24th July 2009, 09:52
I think that it is hard to give you some example because we don't know what is that yellow node. Is it some widget or what? A picture? Diagram in some other application? There are some signals in QLineEdit which you can use (like textChanged() ) so you can connect them to your slots, where you can check the current combo box selection and change proper node (yellow or any other you want). But how would I know how to change that yellow node? Paint it with QPainter or what?

alright. the yellow node is drawn using Qpainter. and the text in the yellow node user "sprintf" to display.

Lykurg
24th July 2009, 09:54
after closing the dialog. i would need to use case method with the combobox i think? as there are 8 choice to select.

After closing the dialog use QComboBox::currentIndex() or QComboBox::currentText() to determinate the box. Either use switch or if/else unless you don't have stored your nodes in a QList etc.

Devoraz
24th July 2009, 09:58
okay first of all. to kickstart. i suppose i have to connect the combobox to the qlineEdit right?

i had look through the some examples and the QT Assistant. but i am still confuse of how to go about connecting it.

Lykurg
24th July 2009, 10:03
okay first of all. to kickstart. i suppose i have to connect the combobox to the qlineEdit right?

i had look through the some examples and the QT Assistant. but i am still confuse of how to go about connecting it.

Come on, what's the problem QCombobox::currentIndexChanged(const QString&) -> QLineEdit::setText()! REad about signal and slot mechanism.

Devoraz
24th July 2009, 10:27
come on. i am very new to this QT library. i am dump to do this project for my Final Year of Diaploma. please be patience with me :D

nish
24th July 2009, 10:31
come on. i am very new to this QT library. i am dump to do this project for my Final Year of Diaploma. please be patience with me :D

then first of all stop using words that made us think you are exp. And use the newbie section..

faldzip
24th July 2009, 14:50
hmm so i think your problem is quite simple:
1. You open a dialog with combo box and line edit
2. Then you edit this dialog and close it
3. After close you want to set the right bubble (yellow for example) with the right text.
Right?

If yes then:
1. If you have some custom dialog (your own subclass of QDialog) just make two methods for it: one to get the selected index and one to get the line edit text. I assume you use QDialog::exec() to open it, so after exec() just read those values and set the right bubble with right text calling your method which paints it (whith QPainter and so on).

2. If you have QDialog object and you set the ui to it (setupUi()) then you can get the values staight form ui object (Ui::SomeDialog).

Devoraz
27th July 2009, 08:17
faldzip. i dont know how to get the selected index of the combobox.

nish
27th July 2009, 08:22
QComboBox::currentIndex ()

Devoraz
27th July 2009, 08:38
can i have an example of code for me try out or something.

nish
27th July 2009, 08:48
brother... just for two minutes try to put yourself in our shoes.. first of all we still dont know what is your exact problem.. secondly you dont seem to be intrested in showing a bit your your code.. thirdly .. you dont know how to use the currentIndex...

seriously... i really doubt your exp. in programming... Did you jumped directly to Qt before learning C++ or flow charts even?? ... I dont want to be harsh.. but you would do yourself a favour if you start reading more of assistant.

or you can wait for our gurus for answers... i am out of luck...

Devoraz
27th July 2009, 09:29
MrDeath. yes i understand. dun doubt my programming. i got all A for my programming module for my diaploma course. i've learn c# c++ htm and mp 8051.

but the problem here is QT library. i am really totally new to it. i am dump with this project for my Final Year Project. i myself is really struggling. i had done alot of change to my GUI.

if i were to show my codes. its a whole lot of things to show =X

i did try to understant the assistant. but it didnt work. i am doing this project on my own, my only hope is you guys from forum.

really need the help. alright. so what izzit that you dun understand of my problems?

nish
27th July 2009, 09:33
ok... the very first process of solving a problem is to isolate it from the rest of the program.
please make a very small compilable program which reproduces your problem. I will not take more than 30 min to make one..

Devoraz
27th July 2009, 09:35
alright. i will try doing it.

but QT is not like C#, when i create the GUI. i can program it by double clicking it.

as for QT, when i use Qt Designer. i could only create the GUI. how do i start programming it. at the very least how do i make the main.cpp to start the "project"

faldzip
27th July 2009, 09:36
can i have an example of code for me try out or something.
There are a lot of examples in Qt Examples & Demos, and a lot of descriptions of methods, classes and everything in Qt Assistant. Just run it and read some text!

Devoraz
27th July 2009, 09:45
alright i will use the example codes to try.

nish
27th July 2009, 09:54
alright. i will try doing it.
thats the way to go!!



but QT is not like C#, when i create the GUI. i can program it by double clicking it.
C# can only be used on windows... Qt is everywhere.. C# programs are at least 10 times slower than Qt(C++).. this is the trade off between speed and ease.



as for QT, when i use Qt Designer. i could only create the GUI. how do i start programming it. at the very least how do i make the main.cpp to start the "project"
now i uderstood your problem... so you have not yet made any program in Qt. Take my advice.. forget about Qt Designer... first try to learn how to code everything by hand written c++. Fire up Qt assistant and look for tutorial.. This is a 10-15 chapter long tutorial which will make you just about good in Qt and you will love it.
If you are in a hurry to make your project its better to make it in C# coz you already know it... remember one thing.. we can only give hints.. nobody can program for you.. and you have at least know the basics of Qt, so that what we try to explain you is understood by you... :)

Devoraz
27th July 2009, 10:04
but the GUI of this project i have is programmed using Qt by Texas Instruments. so i have no choice but to program using Qt...

nish
27th July 2009, 10:12
so better start learning now...

Devoraz
27th July 2009, 10:19
ya damn. if its in C# it will be much much more easier i guess. lol

and i only have 4 weeks left. -_-! i had almost complet my project. this last part is the worst. i manage to slove many of it myself. Qt.... its really nice but really hard -_-!

Devoraz
27th July 2009, 10:27
alright MrDeath. if this question is a yes. i might be able to make what i wan in a simple but not very professional way. lol.

can i have a QLineEdit on top of my Qpainter?

nish
27th July 2009, 10:33
QPainter is a brush which is used to paint on a widget. A widget can have other widgets inside it. So if i understood you correctly... yes you can paint your widget and also have a lineedit on top of it somewhere.

but really brother... please at least spent a day on qt tutorial... you will be gald you did.

Devoraz
27th July 2009, 10:37
ahaha. yes. i am doing it right now in the Qt Assistant with the address book tutorial.

hopefully at the end of it, it will help me someways.

thanks MrDeath. haha. i will come back to you for more question. =)

nish
27th July 2009, 10:45
our "Gurus" can give you more good answers than me :)

Devoraz
27th July 2009, 11:04
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?

nish
27th July 2009, 11:05
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..

Lykurg
27th July 2009, 11:25
eh.. how do i place the position and adjust the length and width of the lineedit ontop of the painter widget?

Read about the layout system of Qt (QBoxLayout, QGridLayout). Don't position them fix!

nish
27th July 2009, 11:28
Read about the layout system of Qt (QBoxLayout, QGridLayout). Don't position them fix!

layouts wont work... he needs to put the widget at a perticular place.. and the parent widget is painted by qpainter so he always know the cordinates

Lykurg
27th July 2009, 11:30
layouts wont work... he needs to put the widget at a perticular place.. and the parent widget is painted by qpainter so he always know the cordinates

Ah, i see, right, this was the yellow bubble thread...:D

faldzip
27th July 2009, 12:27
ya damn. if its in C# it will be much much more easier i guess. lol

and i only have 4 weeks left. -_-! i had almost complet my project. this last part is the worst. i manage to slove many of it myself. Qt.... its really nice but really hard -_-!
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).

Devoraz
28th July 2009, 04:43
Ah, i see, right, this was the yellow bubble thread...:D

LOL yellow bubble thread -_-!


and how many weeks did you have for the project? maybe you should start doing it earlier :]
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.



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.

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.



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).

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.

nvm. i will work harder, its an exposure for me doing this final year project. i love programming. haha.

Devoraz
28th July 2009, 04:51
nameLine = new QLineEdit;
nameLine->setGeometry(QRect(-50,-22,61,21));

why doesnt the lineedit appear on top of my painter widget. i am sure the cord is corret as i tested it with


painter->drawRect(-50,-22,61,21);

the painter appear but not the lineedit.

nish
28th July 2009, 05:08
you have to pass the parent to lineedit

new QLineEdit(this);

Devoraz
28th July 2009, 05:24
you have to pass the parent to lineedit

new QLineEdit(this);

eh.. i got this error..

QLineEdit::QLineEdit(QWidget *)' : cannot convert parameter 1 from 'Node *const ' to 'QWidget *'

all the node is drawn using painter. i cant do this.

nameLine = new QLineEdit(painter);

argh.

nish
28th July 2009, 05:28
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.

Devoraz
28th July 2009, 07:05
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.



void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *)
{
QPixmap pixmap2(200,100);
pixmap2.fill(Qt::white);
QPixmap pix;
QPainter painter1(&pixmap);
QPainter painter2(&pixmap2);
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->setBrush (QColor(0x80, 0x80, 0x80,(nodeData.fadeNumber)));
painter->drawEllipse(-45, -45, 100, 100);

// Set gradient and color of the node
QRadialGradient gradient(0, 0, 50, -20, -20);// access points

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
painter->setPen(QColor(0, 0, 0,(nodeData.fadeNumber)));
// Draw the node
painter->drawEllipse(-50, -50, 100, 100);

//x new text
// White pen for text
if (nodeData.addr==0)
{
painter->setPen(QPen(Qt::white, 1));
}
else
{
if(nodeData.re<100)
{
painter->setPen(QColor(0, 0, 0,(nodeData.fadeNumber)));
}
else
{
painter->setPen(QColor(0xff, 0xff, 0xff,(nodeData.fadeNumber)));
}
}
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->setBrush (QColor(0x80, 0x80, 0x80,(nodeData.fadeNumber)));
painter->drawEllipse(-45, -45, 100, 100);
gradient.setCenter(3, 3);
gradient.setFocalPoint(3, 3);
QRadialGradient gradient(0, 0, 50, -20, -20);
gradient.setColorAt(1, nodeAlertColor);
gradient.setColorAt(.5, nodeAlertColorDark);
gradient.setColorAt(0, nodeAlertColorDark);
painter->setBrush(gradient);
painter->setPen(QColor(0, 0, 0,(nodeData.fadeNumber)));
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->setPen(QPen(Qt::black, 0));
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->setPen(QPen(Qt::black, 0));
painter->setFont(timeFont);
painter->drawText(-50,-50,100,100,Qt::AlignCenter , qsTemp,0);
}
}
painter->drawRect(-43,-20,85,15);
nameLine = new QLineEdit();
nameLine->setGeometry(QRect(-43,-20,85,15)); }

nish
28th July 2009, 07:17
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()

Devoraz
28th July 2009, 07:23
OMG!! argh..

i guess the main widget on which the painter pain on is here. so i write the command of the line edit here?


QRectF Node::boundingRect() const
{
qreal adjust = 2;
return QRectF(-50 - adjust, -50 - adjust,
110 + adjust, 110 + adjust);
}

Devoraz
29th July 2009, 02:56
hello~ Mr.Death~~~

nish
29th July 2009, 04:15
hello there...

make the line edit in constructor of you widget being painted.

Devoraz
29th July 2009, 06:59
hello there...

make the line edit in constructor of you widget being painted.

sorry, but i dun get what you mean by in construtor of my widget

nish
29th July 2009, 07:04
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....

Devoraz
29th July 2009, 07:19
take a look at the example programs that comes with Qt please please....

argh argh argh. why i dun seem to understand. lol. which example? do i look into?

nish
29th July 2009, 07:29
widget painting example..

Devoraz
29th July 2009, 07:46
HELP ME!!! I AM GOING CRAZY! THIS IS KILLING ME!!! can you please help me take a look at the code:????? PLEASE PLEASE PLEASE!!!

this is the .h



#include <QGraphicsItem>
#include <QList>
#include <QTime>
#include <QFont>
#include <QPixmap>
#include <QBrush>
#include <QSound>

#include <qlcdnumber.h>

#include "edge.h"
#include "settingswindow.h"



class Edge;
class NetworkView;
class QGraphicsSceneMouseEvent;
class NodeDb;



class Node : public QGraphicsItem, public QObject
{
public:
typedef enum{ACCESS_POINT, END_DEVICE}NODE_TYPE;
typedef struct
{
NODE_TYPE type;
int addr;
int xPos;
int yPos;
int strength;
float temp;
float voltage;
int re;

int t_time_on;
int fadeNumber;
int fadeTime;
int newNode;
int deletedNode;
}NODE_DATA;

QBrush fill[40];
Node(NetworkView *networkView);
NODE_DATA nodeData;
void addEdge(Edge *edge);
QList<Edge *> edges() const;

enum { Type = UserType + 1 };
int type() const { return Type; }

bool advance();

QRectF boundingRect() const;
QPainterPath shape() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
public slots:
void setLoops() const;


void setNodeData(int index);
void updateData(int index);
int getElapsedTime();
void removeEdge(int childAddr = 0);
int getAddr() { return nodeData.addr; }
float getTemp() { return nodeData.temp; }
int getType() { return nodeData.type; }
void setTempUnit();
void setColor(const NODE_TYPE type);
int Node::find_active_node();
void Node::current_updateData(int index);
int timerId () const;

/*struct colors{
int alpha;
int r;
int g;
int b;
int newnodeflag;
int delnodeflag;
};
struct colors node_colors[100];*/


protected:
QVariant itemChange(GraphicsItemChange change, const QVariant &value);

void timerEvent(QTimerEvent *);

// NODE_DATA nodeData;

private:
QList<Edge *> edgeList;
QPointF newPos;
NetworkView *graph;
QPixmap pixmap,alpha_pix,back_pix,pixmap2,pix;

QColor nodeColor;
QColor nodeColorDark;
QColor nodeAlertColor;
QColor nodeAlertColorDark;

QFont modeFont;
QFont addrFont;
QFont tempFont;
QFont battFont;
QFont strengthFont;
QFont timeFont;
QFont end_deviceFont;
QFont keyFont;
QFont smallFont;
QFont txFont;

QTime timeStamp;
QDate dateStamp;

QLineEdit *nameLine;
NodeDb *pNodeDb;

// Flag used to highlight node.
bool updated;
int updateTimerId,fade_speed,updateTimerId2,updateTime rId3;

bool celsius;
qreal arrowSize;
double nodeAlertTemp;

};

#endif

Devoraz
29th July 2009, 07:48
and the .cpp is attached.

Devoraz
29th July 2009, 07:50
at the very least let me know where is the widget subclass.

nish
29th July 2009, 08:24
QGraphicsItem do not inherit the QWidget class so you cannot place a lineEdit inside it...
what you can do is make another QGraphicsProxyWidget and put lineEdit inside it. read the doc of this.. then like you have inserted your node into a scene... add you proxywidgetitem to the scene as welll.. make sure to play with the z-order of proxywidget so that it always shows above the other items...

Devoraz
29th July 2009, 08:26
QGraphicsItem do not inherit the QWidget class so you cannot place a lineEdit inside it...
what you can do is make another QGraphicsProxyWidget and put lineEdit inside it. read the doc of this.. then like you have inserted your node into a scene... add you proxywidgetitem to the scene as welll.. make sure to play with the z-order of proxywidget so that it always shows above the other items...

NO WONDER!!!! -_-! so what i wan still can be done right? using the QGraphicsProxyWidget class? alright i go read about it. you are a real Guru... lol

wysota
29th July 2009, 09:39
Guys, just reminding you we're dealing with a school project here. Remember about our policy on helping with school projects - only hints, no ready solutions. The guy has to learn and based on the content of this lenghty thread, he needs it. Foremost the "concept of programming" is required. The programming language is just a tool.