Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-989

Reparenting widgets to different screens on X11

    XMLWordPrintable

Details

    Description

      Reparenting widgets to a different display doesn't seem to work very well on X11.

      To reproduce:

      run this example on X11 on a computer with multiple DISPLAY's (e.g. 0.0, 0.1 etc).
      click the radio button to switch screen for a window. Note that the subwidgets don't paint on the new screen (though you can still click on them)

      #include <QtGui>

      class MainWindow : public QMainWindow
      {
      Q_OBJECT
      public:
      MainWindow(int screen)
      : QMainWindow(qApp->desktop()->screen(screen))
      {
      setCentralWidget(new QWidget(this));
      QVBoxLayout *lay = new QVBoxLayout(centralWidget());
      for (int i=0; i<qApp->desktop()->numScreens(); ++i)

      { QRadioButton *rb = new QRadioButton(QString("Screen %1").arg(i), centralWidget()); lay->addWidget(rb); buttons.append(rb); }

      buttons.at(screen)->setChecked(true);
      foreach(QRadioButton *rb, buttons)

      { connect(rb, SIGNAL(toggled(bool)), this, SLOT(changeScreen(bool))); }

      setAttribute(Qt::WA_DeleteOnClose);
      }
      public slots:
      void changeScreen(bool toggled)

      { if (!toggled) return; int s = buttons.indexOf(qobject_cast<QRadioButton*>(sender())); setParent(qApp->desktop()->screen(s)); show(); }

      private:
      QList<QRadioButton*> buttons;
      };

      #include "main.moc"

      int main(int argc, char **argv)
      {
      QApplication a(argc, argv);
      QList<MainWindow*> windows;
      for (int i=0; i<a.desktop()->numScreens(); ++i)

      { MainWindow *mw = new MainWindow(i); windows.append(mw); mw->show(); }

      return a.exec();
      }

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            bhughes Bradley T. Hughes (closed Nokia Identity) (Inactive)
            rve Anders Bakken
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes