Page 3 of 4 FirstFirst 1234 LastLast
Results 41 to 60 of 66

Thread: linking of combox with lineEdit.

  1. #41
    Join Date
    Jul 2009
    Posts
    55
    Thanks
    3

    Default Re: linking of combox with lineEdit.

    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?

  2. #42
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: linking of combox with lineEdit.

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

  3. #43
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: linking of combox with lineEdit.

    Quote Originally Posted by Devoraz View Post
    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!

  4. #44
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: linking of combox with lineEdit.

    Quote Originally Posted by Lykurg View Post
    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

  5. #45
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: linking of combox with lineEdit.

    Quote Originally Posted by MrDeath View Post
    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...

  6. #46
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: linking of combox with lineEdit.

    Quote Originally Posted by Devoraz View Post
    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).
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  7. #47
    Join Date
    Jul 2009
    Posts
    55
    Thanks
    3

    Default Re: linking of combox with lineEdit.

    Quote Originally Posted by Lykurg View Post
    Ah, i see, right, this was the yellow bubble thread...
    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.

  8. #48
    Join Date
    Jul 2009
    Posts
    55
    Thanks
    3

    Default Re: linking of combox with lineEdit.

    Qt Code:
    1. nameLine = new QLineEdit;
    2. nameLine->setGeometry(QRect(-50,-22,61,21));
    To copy to clipboard, switch view to plain text mode 

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

    Qt Code:
    1. painter->drawRect(-50,-22,61,21);
    To copy to clipboard, switch view to plain text mode 

    the painter appear but not the lineedit.

  9. #49
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: linking of combox with lineEdit.

    you have to pass the parent to lineedit

    new QLineEdit(this);

  10. #50
    Join Date
    Jul 2009
    Posts
    55
    Thanks
    3

    Default Re: linking of combox with lineEdit.

    Quote Originally Posted by MrDeath View Post
    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.

  11. #51
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: linking of combox with lineEdit.

    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.

  12. #52
    Join Date
    Jul 2009
    Posts
    55
    Thanks
    3

    Default Re: linking of combox with lineEdit.

    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.


    Qt Code:
    1. void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *)
    2. {
    3. QPixmap pixmap2(200,100);
    4. pixmap2.fill(Qt::white);
    5. QPixmap pix;
    6. QPainter painter1(&pixmap);
    7. QPainter painter2(&pixmap2);
    8. QString id;
    9. Q_UNUSED(option);
    10.  
    11. QSettings settings;
    12. nodeAlertTemp = settings.value("NodeAlertTemp", 10).toDouble();
    13.  
    14. if (nodeData.addr!=0){
    15. if(nodeData.fadeNumber>5&&nodeData.deletedNode!=0)
    16. {
    17. nodeData.fadeNumber-=fade_speed;
    18. if (nodeData.fadeNumber<=5){
    19.  
    20. nodeData.fadeNumber=0;
    21. nodeData.deletedNode=1;
    22. index_number=0;
    23. }
    24. }
    25.  
    26. if(nodeData.fadeNumber<255&&nodeData.newNode!=0)
    27. {
    28. nodeData.fadeNumber+=fade_speed;
    29. if (nodeData.fadeNumber>=255)
    30. {
    31. nodeData.fadeNumber=255;
    32. nodeData.newNode=0;
    33. //current_updateData(index_number);
    34. index_number=0;
    35. }
    36. }
    37. }
    38. // Draw the grey shadow for a 3d effect.
    39. painter->setPen(Qt::NoPen);
    40. painter->setBrush (QColor(0x80, 0x80, 0x80,(nodeData.fadeNumber)));
    41. painter->drawEllipse(-45, -45, 100, 100);
    42.  
    43. // Set gradient and color of the node
    44. QRadialGradient gradient(0, 0, 50, -20, -20);// access points
    45.  
    46. if (nodeData.addr==0&&updated == true)
    47. {
    48. // Mouse click on node or an update of node data~
    49. gradient.setCenter(3, 3);
    50. gradient.setFocalPoint(3, 3);
    51. gradient.setColorAt(1, nodeColor.light(120));
    52. gradient.setColorAt(.5, nodeColorDark.light(120));
    53. gradient.setColorAt(0, nodeColorDark.light(120));
    54. updated = false;
    55. painter->setBrush(gradient);
    56. }
    57. else if (nodeData.addr==0&&updated == false)
    58. {
    59. gradient.setColorAt(0, nodeColor.light(150));
    60. gradient.setColorAt(1, nodeColorDark);
    61. painter->setBrush(gradient);
    62. }
    63. // end devices
    64. if (nodeData.addr!=0&&updated == true)
    65. {
    66. // Mouse click on node or an update of node data~
    67. gradient.setCenter(3, 3);
    68. gradient.setFocalPoint(3, 3);
    69. gradient.setColorAt(1, nodeColor);
    70. gradient.setColorAt(.5, nodeColor);
    71. gradient.setColorAt(0, nodeColor);
    72. updated = false;
    73. painter->setBrush(gradient);
    74. }
    75. else if (nodeData.addr!=0&&updated == false)
    76. {
    77. gradient.setColorAt(0, nodeColor);
    78. gradient.setColorAt(.95, nodeColorDark);
    79. gradient.setColorAt(1, nodeColor);
    80. painter->setBrush(gradient);
    81. }
    82.  
    83.  
    84. // painter->setBrush(gradient);
    85. // Draw black circle around the node
    86. painter->setPen(QColor(0, 0, 0,(nodeData.fadeNumber)));
    87. // Draw the node
    88. painter->drawEllipse(-50, -50, 100, 100);
    89.  
    90. //x new text
    91. // White pen for text
    92. if (nodeData.addr==0)
    93. {
    94. painter->setPen(QPen(Qt::white, 1));
    95. }
    96. else
    97. {
    98. if(nodeData.re<100)
    99. {
    100. painter->setPen(QColor(0, 0, 0,(nodeData.fadeNumber)));
    101. }
    102. else
    103. {
    104. painter->setPen(QColor(0xff, 0xff, 0xff,(nodeData.fadeNumber)));
    105. }
    106. }
    107. QString qsTemp;
    108. QString qsTemp2;
    109. // Write RE
    110. if (nodeData.re>100)
    111. {
    112. rebyte=nodeData.re-100;
    113. }
    114. else
    115. {
    116. rebyte=nodeData.re;
    117. }
    118.  
    119. if (rebyte>4&&nodeData.addr>0)
    120. {
    121. qsTemp.sprintf("%d Sec", rebyte);//rebyte
    122. painter->setFont(timeFont);
    123. painter->drawText(-50,+8,100,20,Qt::AlignCenter , qsTemp,0);
    124. }
    125. else if (nodeData.addr>0)
    126. {
    127. qsTemp.sprintf("%d Min", rebyte);
    128. painter->setFont(timeFont);
    129. painter->drawText(-50,+8,100,20,Qt::AlignCenter , qsTemp,0);
    130. }
    131. else if (nodeData.addr==0)
    132. {
    133. //qsTemp = timeStamp.toString("hh:mm:ss");
    134. qsTemp = timeStamp.toString(Qt::LocalDate);
    135.  
    136. //qsTemp.sprintf("TxCt: %d", cnt_rf);// for Jeff battery test only
    137. painter->setFont(timeFont);
    138. painter->drawText(-50,+5,100,20,Qt::AlignCenter , qsTemp,0);
    139. }
    140. // Write the battery voltage
    141. qsTemp.sprintf("%.1fV", nodeData.voltage);
    142. painter->setFont(battFont);
    143. painter->drawText(-50,+25,100,20,Qt::AlignCenter , qsTemp,0);
    144.  
    145. // Set text in the node
    146. // Write the temperature
    147. if(celsius)
    148. {
    149. qsTemp.sprintf("%.1f°C", ((nodeData.temp-32.0)/1.8));
    150. }
    151. else
    152. {
    153. qsTemp.sprintf("%.1f°F", nodeData.temp);
    154. }
    155. if (nodeData.addr==0) //node 0
    156. {
    157. //xpainter->setFont(tempFont);
    158. painter->setFont(addrFont);
    159. painter->drawText(-50,-45,100,40,Qt::AlignCenter , qsTemp,0);
    160. }
    161. else
    162. {
    163. painter->setFont(timeFont);
    164. painter->drawText(-50,-48,100,40,Qt::AlignCenter , qsTemp,0);
    165. }
    166. if (nodeData.addr==0) //node 0
    167. {
    168. // Write node number
    169. //qsTemp.sprintf("Node: %d", nodeData.addr);
    170. qsTemp.sprintf("Access Point");
    171. //xpainter->setFont(addrFont);
    172. painter->setFont(timeFont);
    173. painter->drawText(-50,-15,100,20,Qt::AlignCenter , qsTemp,0);
    174. }
    175. else
    176. {
    177. // Write node number
    178. // end device details
    179.  
    180. qsTemp.sprintf("End Device %d", nodeData.addr);
    181. //xpainter->setFont(addrFont);
    182. painter->setFont(timeFont);
    183. painter->drawText(-50,-22,100,20,Qt::AlignCenter , qsTemp,0);
    184.  
    185. //Write signal strength in ED node
    186. if (nodeData.strength > 21)
    187. {
    188. qsTemp.sprintf("Strong", nodeData.strength);
    189. painter->setFont(strengthFont);
    190. painter->drawText(-50,-8,100,20,Qt::AlignCenter , qsTemp,0);
    191. }
    192. else if (nodeData.strength > 15)
    193. {
    194. qsTemp.sprintf("Medium", nodeData.strength);
    195. painter->setFont(strengthFont);
    196. painter->drawText(-50,-8,100,20,Qt::AlignCenter , qsTemp,0);
    197. }
    198. else
    199. {
    200. qsTemp.sprintf("Weak", nodeData.strength);
    201. painter->setFont(strengthFont);
    202. painter->drawText(-50,-8,100,20,Qt::AlignCenter , qsTemp,0);
    203. }
    204. //temperture alert,
    205. if(nodeData.temp > (nodeAlertTemp*9)/5+32.0)
    206. {
    207. painter->setPen(Qt::NoPen);
    208. painter->setBrush (QColor(0x80, 0x80, 0x80,(nodeData.fadeNumber)));
    209. painter->drawEllipse(-45, -45, 100, 100);
    210. gradient.setCenter(3, 3);
    211. gradient.setFocalPoint(3, 3);
    212. QRadialGradient gradient(0, 0, 50, -20, -20);
    213. gradient.setColorAt(1, nodeAlertColor);
    214. gradient.setColorAt(.5, nodeAlertColorDark);
    215. gradient.setColorAt(0, nodeAlertColorDark);
    216. painter->setBrush(gradient);
    217. painter->setPen(QColor(0, 0, 0,(nodeData.fadeNumber)));
    218. painter->drawEllipse(-50, -50, 100, 100);
    219. if(celsius)
    220. {
    221. qsTemp.sprintf("ALERT!\n\ End Device %d\n\ %.1f°C\n\ ", nodeData.addr, ((nodeData.temp-32.0)/1.8));
    222. painter->setPen(QPen(Qt::black, 0));
    223. painter->setFont(timeFont);
    224. painter->drawText(-50,-50,100,100,Qt::AlignCenter , qsTemp,0);
    225. }
    226. else
    227. {
    228. qsTemp.sprintf("ALERT!\n\ End Device %d\n\ %.1f°F\n\ ", nodeData.addr, nodeData.temp);
    229. painter->setPen(QPen(Qt::black, 0));
    230. painter->setFont(timeFont);
    231. painter->drawText(-50,-50,100,100,Qt::AlignCenter , qsTemp,0);
    232. }
    233. }
    234. painter->drawRect(-43,-20,85,15);
    235. [COLOR="blue"]nameLine = new QLineEdit();
    236. nameLine->setGeometry(QRect(-43,-20,85,15));[/COLOR] }
    To copy to clipboard, switch view to plain text mode 

  13. #53
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: linking of combox with lineEdit.

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

  14. #54
    Join Date
    Jul 2009
    Posts
    55
    Thanks
    3

    Default Re: linking of combox with lineEdit.

    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?

    Qt Code:
    1. QRectF Node::boundingRect() const
    2. {
    3. qreal adjust = 2;
    4. return QRectF(-50 - adjust, -50 - adjust,
    5. 110 + adjust, 110 + adjust);
    6. }
    To copy to clipboard, switch view to plain text mode 

  15. #55
    Join Date
    Jul 2009
    Posts
    55
    Thanks
    3

    Default Re: linking of combox with lineEdit.

    hello~ Mr.Death~~~

  16. #56
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: linking of combox with lineEdit.

    hello there...

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

  17. #57
    Join Date
    Jul 2009
    Posts
    55
    Thanks
    3

    Default Re: linking of combox with lineEdit.

    Quote Originally Posted by MrDeath View Post
    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

  18. #58
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: linking of combox with lineEdit.

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

  19. #59
    Join Date
    Jul 2009
    Posts
    55
    Thanks
    3

    Default Re: linking of combox with lineEdit.

    Quote Originally Posted by MrDeath View Post
    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?

  20. #60
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: linking of combox with lineEdit.

    widget painting example..

Similar Threads

  1. Qt linking problem
    By LovesTha in forum Newbie
    Replies: 3
    Last Post: 30th March 2009, 23:31
  2. How to update lineEdit
    By HelloDan in forum Qt Programming
    Replies: 9
    Last Post: 17th February 2009, 07:01
  3. Copy / Paste doesn't work with LineEdit
    By ia32 in forum Qt Tools
    Replies: 2
    Last Post: 5th May 2008, 21:44
  4. Replies: 4
    Last Post: 20th February 2006, 09:11
  5. subclassing or redrawing a lineEdit
    By jayw710 in forum Qt Programming
    Replies: 2
    Last Post: 7th February 2006, 18:26

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.