Hello,

I've got two monitors in Linux configured as multi-screen, so I've two monitors connected to one graphic card. I'm trying to display a QWidget on upper or lower monitor using QDesktopWidget, but I'm doing something wrong because I can't do it.

I leave some code below to understand better my issue:

The class inherits QWidget:

Qt Code:
  1. IFHMIQtGui(QWidget* parent, GUIDevice device)
To copy to clipboard, switch view to plain text mode 

The constructor:

Qt Code:
  1. IFHMIQtGui::IFHMIQtGui(QWidget* parent, GUIDevice device)
  2. {
  3. QDesktopWidget pDesktop;
  4. QWidget *qscreen;
  5.  
  6. if (device == DEVICE_UPPER)
  7. {
  8. qscreen = pDesktop.screen(1);
  9. }
  10. else if (device == DEVICE_LOWER)
  11. {
  12. qscreen = pDesktop.screen(0);
  13. }
  14.  
  15. QWidget(qscreen);
  16. }
To copy to clipboard, switch view to plain text mode 

I know that if I pass the QDesktopWidget to my IFHMIQtGui when I contruct the object, the QWidget is displayed on the right monitor. Anyway, the problem is that I need to use QDesktopWidget inside the IFHMIQtGui constructor.

Thank you.