本文整理汇总了C++中QDesktopWidget::numScreens方法的典型用法代码示例。如果您正苦于以下问题:C++ QDesktopWidget::numScreens方法的具体用法?C++ QDesktopWidget::numScreens怎么用?C++ QDesktopWidget::numScreens使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDesktopWidget
的用法示例。
在下文中一共展示了QDesktopWidget::numScreens方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: reallocScreenWidgets
// Refresh the screen widgets pool, depending on stored drawings
void ScreenBoard::reallocScreenWidgets() {
QDesktopWidget *desktop = QApplication::desktop();
int i, screensCount = desktop->numScreens();
// Delete exceeding screens and resize to screensCount
for (i = screensCount; i < m_screenWidgets.size(); ++i) {
m_screenWidgets[i]->hide();
m_screenWidgets[i]->deleteLater(); // Ensures no event about it is pending.
// Note that updates may be invoked in event handlers.
}
m_screenWidgets.resize(desktop->numScreens());
// Re-initialize the screen widgets list
for (i = 0; i < screensCount; ++i) {
ScreenWidget *screenWidget = m_screenWidgets[i];
if (screenWidget) screenWidget->drawings().clear();
}
// Turn on a ScreenWidget for each screen crossed by any drawing
int j, drawingsCount = m_drawings.size();
for (i = 0; i < screensCount; ++i) {
ScreenWidget *screenWidget = m_screenWidgets[i];
const QRect &screenGeom = desktop->screenGeometry(i);
for (j = 0; j < drawingsCount; ++j) {
Drawing *drawing = m_drawings[j];
if (drawing->acceptScreenEvents(screenGeom)) {
// Allocate the associated screen widget if necessary
if (!screenWidget) {
m_screenWidgets[i] = screenWidget = new ScreenWidget(0, m_grabbing);
if (m_grabbing) screenWidget->setCursor(m_cursor);
screenWidget->setGeometry(screenGeom);
screenWidget->show();
}
// Add the drawing to the widget
screenWidget->drawings().push_back(drawing);
}
}
}
// Remove screens without drawings
for (i = 0; i < screensCount; ++i) {
ScreenWidget *screenWidget = m_screenWidgets[i];
if (screenWidget && screenWidget->drawings().empty()) {
screenWidget->hide();
screenWidget->deleteLater();
m_screenWidgets[i] = 0;
}
}
}
示例2: getVideoDevices
void MediaSourceDesktop::getVideoDevices(VideoDevices &pVList)
{
static bool tFirstCall = true;
VideoDeviceDescriptor tDevice;
#ifdef MSD_DEBUG_PACKETS
tFirstCall = true;
#endif
if (tFirstCall)
LOG(LOG_VERBOSE, "Enumerating hardware..");
//#############################
//### screen segment
//#############################
tDevice.Name = MEDIA_SOURCE_DESKTOP;
tDevice.Card = "segment";
#ifdef APPLE
tDevice.Desc = "OSX Cocoa based screen segment capturing";
#else
tDevice.Desc = "Qt based screen segment capturing";
#endif
if (tFirstCall)
LOG(LOG_VERBOSE, "Found video device: %s (card: %s)", tDevice.Name.c_str(), tDevice.Card.c_str());
pVList.push_back(tDevice);
QDesktopWidget *tDesktop = QApplication::desktop();
if (tDesktop != NULL)
{
if (tFirstCall)
{
LOG(LOG_VERBOSE, "Desktop found..");
LOG(LOG_VERBOSE, " ..resolution: %d * %d", tDesktop->width(), tDesktop->height());
LOG(LOG_VERBOSE, " ..screens: %d", tDesktop->numScreens());
LOG(LOG_VERBOSE, " ..virtualized: %d", tDesktop->isVirtualDesktop());
}
for (int i = 0; i < tDesktop->numScreens(); i++)
{
QWidget *tScreen = tDesktop->screen(i);
if (tFirstCall)
{
LOG(LOG_VERBOSE, " ..screen %d: resolution=%d*%d, available resolution=%d*%d, position=(%d, %d)", i, tDesktop->screenGeometry(i).width(), tDesktop->screenGeometry(i).height(), tDesktop->availableGeometry(i).width(), tDesktop->availableGeometry(i).height(), tDesktop->screenGeometry(i).x(), tDesktop->screenGeometry(i).y());
}
}
}
tFirstCall = false;
}
示例3: GetScreenNumber
unsigned int QtWidgetsTweakletImpl::GetScreenNumber()
{
QDesktopWidget *desktop = QApplication::desktop();
// get the primary screen
unsigned int numScreens = desktop->numScreens();
return numScreens;
}
示例4: desktopManager
void Application::desktopManager(bool enabled) {
// TODO: turn on or turn off desktpo management (desktop icons & wallpaper)
qDebug("desktopManager: %d", enabled);
QDesktopWidget* desktopWidget = desktop();
if(enabled) {
if(!enableDesktopManager_) {
installNativeEventFilter(this);
Q_FOREACH(QScreen* screen, screens()) {
connect(screen, &QScreen::virtualGeometryChanged, this, &Application::onVirtualGeometryChanged);
connect(screen, &QObject::destroyed, this, &Application::onScreenDestroyed);
}
connect(this, &QApplication::screenAdded, this, &Application::onScreenAdded);
connect(desktopWidget, SIGNAL(resized(int)), SLOT(onScreenResized(int)));
connect(desktopWidget, SIGNAL(screenCountChanged(int)), SLOT(onScreenCountChanged(int)));
// NOTE: there are two modes
// When virtual desktop is used (all screens are combined to form a large virtual desktop),
// we only create one DesktopWindow. Otherwise, we create one for each screen.
if(desktopWidget->isVirtualDesktop()) {
DesktopWindow* window = createDesktopWindow(-1);
desktopWindows_.push_back(window);
}
else {
int n = desktopWidget->numScreens();
desktopWindows_.reserve(n);
for(int i = 0; i < n; ++i) {
DesktopWindow* window = createDesktopWindow(i);
desktopWindows_.push_back(window);
}
}
}
示例5: KDialog
SCConfigurePresenterViewDialog::SCConfigurePresenterViewDialog(SCDocument *document, QWidget *parent)
: KDialog(parent)
, m_document(document)
{
QWidget *widget = new QWidget(this);
ui.setupUi(widget);
QDesktopWidget desktop;
int numScreens = desktop.numScreens();
int primaryScreen = desktop.primaryScreen();
for (int i = 0; i < numScreens; i++) {
if (i == primaryScreen) {
ui.monitorComboBox->addItem(i18n("Monitor %1 (primary)", i + 1));
}
else {
ui.monitorComboBox->addItem(i18n("Monitor %1", i + 1));
}
}
if (numScreens <= 1)
ui.presenterViewCheckBox->setEnabled(false);
setMainWidget(widget);
setCaption(i18n("Configure Presenter View"));
ui.monitorComboBox->setCurrentIndex(document->presentationMonitor());
ui.presenterViewCheckBox->setChecked(
document->isPresenterViewEnabled() ? Qt::Checked : Qt::Unchecked);
}
示例6: screenGeometry
EXPORT QRect screenGeometry(unsigned nScreen)
{
QDesktopWidget *desktop = QApplication::desktop();
if(nScreen == ~0U) {
QRect rc;
for (int i = 0; i < desktop->numScreens(); i++){
rc |= desktop->screenGeometry(i);
}
return rc;
}
return desktop->screenGeometry(nScreen);
}
示例7:
bool
UBBoardView::isAbsurdPoint (QPoint point)
{
QDesktopWidget *desktop = qApp->desktop ();
bool isValidPoint = false;
for (int i = 0; i < desktop->numScreens (); i++)
{
QRect screenRect = desktop->screenGeometry (i);
isValidPoint = isValidPoint || screenRect.contains (point);
}
return !isValidPoint;
}
示例8: QDockWidget
LayerManager::LayerManager(ItemDB *itemDb, QWidget *parent) :
QDockWidget(parent),
ui(new Ui::LayerManager),
m_itemDb(itemDb),
m_clipboardIndex()
{
ui->setupUi(this);
this->setStyleSheet(StylesheetProvider::getStylesheet("QTreeView,LayerManager"));
QDesktopWidget desktopWidget;
QRect rightScreenRect = desktopWidget.screenGeometry(desktopWidget.numScreens() -1);
if (desktopWidget.screenCount() > 1) {
this->resize(this->width(), rightScreenRect.height());
this->move(rightScreenRect.topLeft());
}
ui->treeView_layer->setItemDelegate(new TreeViewItemDelegate(this));
ui->treeView_layer->setModel(m_itemDb);
ui->treeView_layer->setColumnWidth(1, 24);
ui->treeView_layer->setColumnWidth(2, 24);
ui->treeView_layer->setColumnWidth(3, 24);
ui->treeView_layer->header()->setSectionResizeMode(0, QHeaderView::Stretch);
ui->treeView_layer->header()->setSectionResizeMode(1, QHeaderView::Fixed);
ui->treeView_layer->header()->setSectionResizeMode(2, QHeaderView::Fixed);
ui->treeView_layer->header()->setSectionResizeMode(3, QHeaderView::Fixed);
ui->treeView_layer->header()->setSectionResizeMode(4, QHeaderView::ResizeToContents);
ui->treeView_layer->header()->setSectionResizeMode(5, QHeaderView::ResizeToContents);
ui->treeView_layer->header()->setSectionResizeMode(6, QHeaderView::ResizeToContents);
ui->treeView_layer->header()->setSectionResizeMode(7, QHeaderView::ResizeToContents);
m_menuNoItem = new QMenu(this);
m_menuNoItem->addAction(tr("New layer"), this, SLOT(slot_appendNewLayer()));
m_menuOnItem = new QMenu(this);
m_menuOnItem->addAction(tr("Edit name"), this, SLOT(slot_editLayerName()));
m_menuOnItem->addAction(tr("Edit line width"), this, SLOT(slot_editLayerLineWidth()));
m_menuOnItem->addAction(tr("Edit line type"), this, SLOT(slot_editLayerLineType()));
m_menuOnItem->addSeparator();
m_menuOnItem->addAction(tr("Append new Layer"), this, SLOT(slot_appendNewLayer()));
m_menuOnItem->addAction(tr("Append new Layer as child"), this, SLOT(slot_appendNewLayerAsChild()));
m_menuOnItem->addAction(tr("Delete layer"), this, SLOT(slot_deleteLayer()));
m_menuOnItem->addSeparator();
m_actionCut = m_menuOnItem->addAction(tr("Cut"), this, SLOT(slot_cutLayer()));
m_actionPasteHere = m_menuOnItem->addAction(tr("Paste here"), this, SLOT(slot_pasteLayerHere()));
m_actionPasteAsChild = m_menuOnItem->addAction(tr("Paste as child"), this, SLOT(slot_pasteLayerAsChild()));
m_actionPasteHere->setDisabled(true);
m_actionPasteAsChild->setDisabled(true);
}
示例9: screenNumberForQWidget
void tst_QDesktopWidget::screenNumberForQWidget()
{
QDesktopWidget desktop;
QCOMPARE(desktop.screenNumber(0), 0);
QWidget widget;
widget.show();
QApplication::processEvents();
QVERIFY(widget.isVisible());
int widgetScreen = desktop.screenNumber(&widget);
QVERIFY(widgetScreen > -1);
QVERIFY(widgetScreen < desktop.numScreens());
}
示例10:
PresenterConfiguration::PresenterConfiguration(IEventBus * bus) {
QDesktopWidget * desktopWidget = QApplication::desktop();
this->mainScreen = desktopWidget->primaryScreen();
this->auxScreen = desktopWidget->primaryScreen();
for (int i = 0 ; i < desktopWidget->numScreens() ; i++) {
if (i != this->mainScreen) {
this->auxScreen = i;
break;
}
}
this->parser = NULL;
this->document = NULL;
this->renderer = NULL;
this->bus = bus;
}
示例11: readSettings
void CelestiaAppWindow::readSettings()
{
QDesktopWidget desktop;
QSettings settings;
settings.beginGroup("MainWindow");
QSize windowSize = settings.value("Size", DEFAULT_MAIN_WINDOW_SIZE).toSize();
QPoint windowPosition = settings.value("Pos", DEFAULT_MAIN_WINDOW_POSITION).toPoint();
// Make sure that the saved size fits on screen; it's possible for the previous saved
// position to be off-screen if the monitor settings have changed.
bool onScreen = false;
for (int screenIndex = 0; screenIndex < desktop.numScreens(); screenIndex++)
{
QRect screenGeometry = desktop.screenGeometry(screenIndex);
if (screenGeometry.contains(windowPosition))
onScreen = true;
}
if (!onScreen)
{
windowPosition = DEFAULT_MAIN_WINDOW_POSITION;
windowSize = DEFAULT_MAIN_WINDOW_SIZE;
}
resize(windowSize);
move(windowPosition);
if (settings.contains("State"))
restoreState(settings.value("State").toByteArray(), CELESTIA_MAIN_WINDOW_VERSION);
if (settings.value("Fullscreen", false).toBool())
showFullScreen();
settings.endGroup();
// Render settings read in qtglwidget
}
示例12: activate
void KPrViewModePresentation::activate( KoPAViewMode * previousViewMode )
{
if (!m_baseCanvas) return;
m_savedViewMode = previousViewMode; // store the previous view mode
m_savedParent = m_baseCanvas->parentWidget();
m_baseCanvas->setParent( ( QWidget* )0, Qt::Window ); // set parent to 0 and
QDesktopWidget desktop;
KPrDocument *document = static_cast<KPrDocument *>( m_view->kopaDocument() );
bool presenterViewEnabled = document->isPresenterViewEnabled();
int presentationscreen = document->presentationMonitor();
// add end off slideshow page
m_endOfSlideShowPage = new KPrEndOfSlideShowPage( desktop.screenGeometry( presentationscreen ), document );
QList<KoPAPageBase*> pages = document->slideShow();
pages.append( m_endOfSlideShowPage );
QRect presentationRect = desktop.screenGeometry( presentationscreen );
#ifdef Q_OS_LINUX
// This breaks and is not required on Windows platforms
m_baseCanvas->setParent(desktop.screen(presentationscreen), Qt::Window); // detach widget to the presentation screen
#endif
m_baseCanvas->setWindowFlags( Qt::Window ); // make it a window
// the main animation director needs to be created first since it will set the active page
// of the presentation
// the animation director needs to be set before m_baseCanvas->move is called as this might try to call
// viewConverter.
m_animationDirector = new KPrAnimationDirector( m_view, m_baseCanvas, pages, m_view->activePage() );
// move and resize now as otherwise it is not set when we call activate on the tool.
m_baseCanvas->setGeometry(presentationRect);
m_baseCanvas->setWindowState( m_baseCanvas->windowState() | Qt::WindowFullScreen ); // make it show full screen
// show and setFocus needs to be done after move and resize as otherwise the move and resize have no effect
m_baseCanvas->show();
m_baseCanvas->setFocus();
KoCursor::setAutoHideCursor( m_baseCanvas, true );
if ( presenterViewEnabled ) {
if ( desktop.numScreens() > 1 ) {
int newscreen = desktop.numScreens() - presentationscreen - 1; // What if we have > 2 screens?
QRect pvRect = desktop.screenGeometry( newscreen );
m_presenterViewCanvas = new KoPACanvas( m_view, document );
m_presenterViewWidget = new KPrPresenterViewWidget( this, pages, m_presenterViewCanvas );
#ifdef Q_OS_LINUX
// This breaks and is not required on Windows platforms
m_presenterViewWidget->setParent( desktop.screen(newscreen), Qt::Window );
#endif
m_presenterViewWidget->setGeometry(pvRect);
m_presenterViewWidget->setWindowState(
m_presenterViewWidget->windowState() | Qt::WindowFullScreen );
m_presenterViewWidget->updateWidget( pvRect.size(), presentationRect.size() );
m_presenterViewWidget->show();
m_presenterViewWidget->setFocus(); // it shown full screen
m_pvAnimationDirector = new KPrAnimationDirector( m_view,
m_presenterViewCanvas, pages, m_view->activePage() );
}
else {
kWarning() << "Presenter View is enabled but only found one monitor";
document->setPresenterViewEnabled( false );
}
}
m_tool->activate(KoToolBase::DefaultActivation, QSet<KoShape*>());
emit activated();
emit pageChanged( m_animationDirector->currentPage(), m_animationDirector->numStepsInPage() );
emit stepChanged( m_animationDirector->currentStep() );
}
示例13: GetScreenBounds
/**
* \brief Get screen size from Qt, respecting for user's multiple screen prefs
*
* If the windowing system environment has multiple screens
* (%e.g. Xinerama or Mac OS X), QApplication::desktop()->%width() will span
* all of them, so we usually need to get the geometry of a specific screen.
*/
void MythUIHelperPrivate::GetScreenBounds()
{
QDesktopWidget *desktop = QApplication::desktop();
bool hasXinerama = MythDisplay::GetNumberXineramaScreens() > 1;
int numScreens = desktop->numScreens();
int screen;
if (hasXinerama)
{
LOG(VB_GUI, LOG_INFO, LOC +
QString("Total desktop dim: %1x%2, over %3 screen[s].")
.arg(desktop->width()).arg(desktop->height()).arg(numScreens));
}
if (numScreens > 1)
{
for (screen = 0; screen < numScreens; ++screen)
{
QRect dim = desktop->screenGeometry(screen);
LOG(VB_GUI, LOG_INFO, LOC + QString("Screen %1 dim: %2x%3.")
.arg(screen).arg(dim.width()).arg(dim.height()));
}
}
screen = desktop->primaryScreen();
LOG(VB_GUI, LOG_INFO, LOC + QString("Primary screen: %1.").arg(screen));
if (hasXinerama)
screen = GetMythDB()->GetNumSetting("XineramaScreen", screen);
if (screen == -1) // Special case - span all screens
{
m_xbase = 0;
m_ybase = 0;
m_width = desktop->width();
m_height = desktop->height();
LOG(VB_GUI, LOG_INFO, LOC +
QString("Using all %1 screens. ").arg(numScreens) +
QString("Dimensions: %1x%2").arg(m_width).arg(m_height));
return;
}
if (hasXinerama) // User specified a single screen
{
if (screen < 0 || screen >= numScreens)
{
LOG(VB_GENERAL, LOG_WARNING, LOC +
QString("Xinerama screen %1 was specified,"
" but only %2 available, so using screen 0.")
.arg(screen).arg(numScreens));
screen = 0;
}
}
{
QRect bounds;
bool inWindow = GetMythDB()->GetNumSetting("RunFrontendInWindow", 0);
if (inWindow)
LOG(VB_GUI, LOG_INFO, LOC + "Running in a window");
if (inWindow)
// This doesn't include the area occupied by the
// Windows taskbar, or the Mac OS X menu bar and Dock
bounds = desktop->availableGeometry(screen);
else
bounds = desktop->screenGeometry(screen);
m_xbase = bounds.x();
m_ybase = bounds.y();
m_width = bounds.width();
m_height = bounds.height();
LOG(VB_GUI, LOG_INFO, LOC + QString("Using screen %1, %2x%3 at %4,%5")
.arg(screen).arg(m_width).arg(m_height)
.arg(m_xbase).arg(m_ybase));
}
}
示例14: screens
EXPORT unsigned screens()
{
QDesktopWidget *desktop = QApplication::desktop();
return desktop->numScreens();
}
示例15: relayoutItems
// QListView does item layout in a very inflexible way, so let's do our custom layout again.
// FIXME: this is very inefficient, but due to the design flaw of QListView, this is currently the only workaround.
void DesktopWindow::relayoutItems() {
loadItemPositions(); // something may have changed
// qDebug("relayoutItems()");
if(relayoutTimer_) {
// this slot might be called from the timer, so we cannot delete it directly here.
relayoutTimer_->deleteLater();
relayoutTimer_ = NULL;
}
QDesktopWidget* desktop = qApp->desktop();
int screen = 0;
int row = 0;
int rowCount = proxyModel_->rowCount();
for(;;) {
if(desktop->isVirtualDesktop()) {
if(screen >= desktop->numScreens())
break;
}else {
screen = screenNum_;
}
QRect workArea = desktop->availableGeometry(screen);
workArea.adjust(12, 12, -12, -12); // add a 12 pixel margin to the work area
// qDebug() << "workArea" << screen << workArea;
// FIXME: we use an internal class declared in a private header here, which is pretty bad.
QSize grid = listView_->gridSize();
QPoint pos = workArea.topLeft();
for(; row < rowCount; ++row) {
QModelIndex index = proxyModel_->index(row, 0);
int itemWidth = delegate_->sizeHint(listView_->getViewOptions(), index).width();
FmFileInfo* file = proxyModel_->fileInfoFromIndex(index);
QByteArray name = fm_file_info_get_name(file);
QHash<QByteArray, QPoint>::iterator it = customItemPos_.find(name);
if(it != customItemPos_.end()) { // the item has a custom position
QPoint customPos = *it;
// center the contents vertically
listView_->setPositionForIndex(customPos + QPoint((grid.width() - itemWidth) / 2, 0), index);
// qDebug() << "set custom pos:" << name << row << index << customPos;
continue;
}
// check if the current pos is alredy occupied by a custom item
bool used = false;
for(it = customItemPos_.begin(); it != customItemPos_.end(); ++it) {
QPoint customPos = *it;
if(QRect(customPos, grid).contains(pos)) {
used = true;
break;
}
}
if(used) { // go to next pos
--row;
}
else {
// center the contents vertically
listView_->setPositionForIndex(pos + QPoint((grid.width() - itemWidth) / 2, 0), index);
// qDebug() << "set pos" << name << row << index << pos;
}
// move to next cell in the column
pos.setY(pos.y() + grid.height() + listView_->spacing());
if(pos.y() + grid.height() > workArea.bottom() + 1) {
// if the next position may exceed the bottom of work area, go to the top of next column
pos.setX(pos.x() + grid.width() + listView_->spacing());
pos.setY(workArea.top());
// check if the new column exceeds the right margin of work area
if(pos.x() + grid.width() > workArea.right() + 1) {
if(desktop->isVirtualDesktop()) {
// in virtual desktop mode, go to next screen
++screen;
break;
}
}
}
}
if(row >= rowCount)
break;
}
}