Results 1 to 1 of 1

Thread: QT code is not working on Windows, but it does on Linux/Mac

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2021
    Posts
    1
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Question QT code is not working on Windows, but it does on Linux/Mac

    Hi!

    I'm having an issue with an app created with QT5. The same code is working properly on Linux/Mac, but on Windows despite of it's executing when I want to execute a submenu clicking with the right botton of the mouse it doesn't respond and doesn't show the submenu. Sometimes de submenu appears but in a very random way. I don't know why is happening this, on the others OS the submenu appears without any problems. I'm using the same package versions.

    Code:

    Qt Code:
    1. def contextMenuEvent(self, event):
    2. try:
    3. if self.cursor_mode:
    4. if self.click_box!=None and self.bboxes!=None:
    5. #print(self.bboxes)
    6. for index, b in enumerate(self.bboxes):
    7. if b[0].x()<self.click_box.x()<b[1].x() and \
    8. b[0].y()<self.click_box.y()<b[1].y():
    9. #print(index,b)
    10. menu = QMenu()
    11. actionSet = []
    12. for key, value in self.ind_to_class.items():
    13. if 'prod' in value:
    14. menu_opt = menu.addMenu(value)
    15. for i in range(1, 21):
    16. if 'prod' in b[2]:
    17. btwo = b[2].rsplit('_')
    18. type_prod = btwo[1]
    19. prod_num = btwo[2]
    20. #print(btwo, type_prod, prod_num)
    21.  
    22. if int(prod_num) == i and type_prod in value:
    23. color1 = str(self.gt_color[key][0])
    24. color2 = str(self.gt_color[key][1])
    25. color3 = str(self.gt_color[key][2])
    26. action_high = QtWidgets.QWidgetAction(menu)
    27. label = QtWidgets.QLabel(b[2])
    28. label.setStyleSheet("QLabel { color: " + self.text_color[
    29. key] + "; background-color: rgb(" + color1 + "," + color2 + "," + color3 + "); padding: 5px 25px 5px 25px; } QLabel:hover { color: rgb(255,255,255); background-color: #00457d;}")
    30. action_high.setDefaultWidget(label)
    31. action_high.setText(b[2])
    32. menu_opt.addAction(action_high)
    33. else:
    34. menu_opt.addAction(str(value) + '_' + str(i))
    35. else:
    36. menu_opt.addAction(str(value) + '_' + str(i))
    37. else:
    38. if value == b[2]:
    39. color1 = str(self.gt_color[key][0])
    40. color2 = str(self.gt_color[key][1])
    41. color3 = str(self.gt_color[key][2])
    42. action_high = QtWidgets.QWidgetAction(menu)
    43. label = QtWidgets.QLabel(value)
    44. label.setStyleSheet("QLabel { color: " + self.text_color[key] + "; background-color: rgb(" + color1 + "," + color2 + "," + color3 + "); padding: 5px 25px 5px 25px; } QLabel:hover { color: rgb(255,255,255); background-color: #00457d;}")
    45. action_high.setDefaultWidget(label)
    46. action_high.setText(value)
    47. menu.addAction(action_high)
    48.  
    49. else:
    50. menu.addAction(value)
    51. actionSet.append(menu)
    52. action = menu.exec_(event.screenPos())
    53.  
    54. if action:
    55. self.bboxes[index][2] = action.text()
    56.  
    57. elif not self.cursor_mode:
    58. #print(self.click_boxes)
    59. if len(self.click_boxes) > 0 and self.bboxes!=None:
    60. menu = QMenu()
    61. actionSet = []
    62. for key, value in self.ind_to_class.items():
    63. ##########actionSet.append(menu.addAction(value))
    64.  
    65. if 'prod' in value:
    66. menu_opt = menu.addMenu(value)
    67. for i in range(1, 21):
    68. menu_opt.addAction(str(value) + '_' + str(i))
    69. else:
    70. menu.addAction(value)
    71.  
    72. actionSet.append(menu)
    73. action = menu.exec_(event.screenPos())
    74.  
    75. ind_sel = None
    76. #for indi, vali in enumerate(actionSet):
    77. # if action == vali:
    78. # ind_sel = indi
    79.  
    80.  
    81. #print("Class selected: "+str(ind_sel))
    82. for index, b in enumerate(self.click_boxes):
    83. self.bboxes[b[4]-1][2] = action.text()#self.ind_to_class[ind_sel]
    84.  
    85. self.click_boxes = []
    86. self.draw_box = False
    87. self.click = 0
    88. except:
    89. print('Problem')
    90. if self.print_callback != None:
    91. self.print_callback(self.bboxes)
    To copy to clipboard, switch view to plain text mode 
    Thanks!
    Teresa
    Last edited by d_stranz; 16th April 2021 at 17:51. Reason: missing [code] tags

Similar Threads

  1. Replies: 1
    Last Post: 12th September 2014, 21:07
  2. application not executing in windows, in linux its working
    By sujan.dasmahapatra in forum Qt Programming
    Replies: 2
    Last Post: 19th January 2012, 10:11
  3. Replies: 2
    Last Post: 2nd August 2011, 16:05
  4. Replies: 4
    Last Post: 9th January 2008, 16:28
  5. C code linux to windows
    By deekayt in forum General Discussion
    Replies: 1
    Last Post: 19th October 2006, 23:17

Tags for this Thread

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.