本文整理汇总了C++中QDesktopWidget::screenCount方法的典型用法代码示例。如果您正苦于以下问题:C++ QDesktopWidget::screenCount方法的具体用法?C++ QDesktopWidget::screenCount怎么用?C++ QDesktopWidget::screenCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDesktopWidget
的用法示例。
在下文中一共展示了QDesktopWidget::screenCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
void RegionGrab::init()
{
m_pixmap = m_grabber->grabFullScreen();
QDesktopWidget *desktop = QApplication::desktop();
QRect rect;
if (desktop->screenCount() > 1) {
for (int i = 0; i < desktop->screenCount(); ++i) {
if (rect.isNull())
rect = desktop->screenGeometry(i);
else
rect = rect.united(desktop->screenGeometry(i));
}
}
else
rect = QRect(QPoint(0, 0), m_pixmap.size());
resize(rect.size());
move(rect.topLeft());
setCursor(Qt::CrossCursor);
# ifdef Q_OS_MAC
showFullScreen();
# else
show();
# endif
raise();
activateWindow();
setFocus();
}
示例2: setSoundFile
void WaveformWidget::setSoundFile(QString filename)
{
QPainterPath waveformMax(QPointF(0,0));
QPainterPath waveformMin(QPointF(0,0));
SndfileHandle soundFile(filename.toStdString());
if (soundFile.error()) qDebug() << soundFile.strError();
QDesktopWidget *desk = QApplication::desktop();
int totalPixelCount = (desk->screenGeometry().width()*desk->screenCount());
sf_count_t framesPerPixel = soundFile.frames()/totalPixelCount;
Q_ASSERT(framesPerPixel >= 1);
float samples[framesPerPixel*soundFile.channels()];
sf_count_t totalFrames = 0;
while (soundFile.readf(samples, framesPerPixel) != 0) {
float maximum = 0;
float minimum = 0;
for (int f=0; f<framesPerPixel; f++) {
for (int c=0; c<soundFile.channels(); c++) {
maximum = samples[f*c+c] > maximum ? samples[f*c+c] : maximum;
minimum = samples[f*c+c] < minimum ? samples[f*c+c] : minimum;
}
}
waveformMax.lineTo(double(totalFrames)/(framesPerPixel*totalPixelCount), maximum);
waveformMin.lineTo(double(totalFrames)/(framesPerPixel*totalPixelCount), minimum);
totalFrames += framesPerPixel;
}
maxWave.swap(waveformMax);
minWave.swap(waveformMin);
}
示例3: movePointOntoDesktop
QPoint InviwoApplicationQt::movePointOntoDesktop(const QPoint& point, const QSize& size,
bool decorationOffset) {
QPoint pos(point);
if (movePointsOn_) {
QDesktopWidget* desktop = QApplication::desktop();
int primaryScreenIndex = desktop->primaryScreen();
QRect wholeScreen = desktop->screenGeometry(primaryScreenIndex);
for (int i = 0; i < desktop->screenCount(); i++) {
if (i != primaryScreenIndex) wholeScreen = wholeScreen.united(desktop->screenGeometry(i));
}
wholeScreen.setRect(wholeScreen.x() - 10, wholeScreen.y() - 10, wholeScreen.width() + 20,
wholeScreen.height() + 20);
QPoint bottomRight = QPoint(point.x() + size.width(), point.y() + size.height());
QPoint appPos = getMainWindow()->pos();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
if (decorationOffset) {
QPoint offset = getWindowDecorationOffset();
pos -= offset;
}
#endif
if (!wholeScreen.contains(pos) || !wholeScreen.contains(bottomRight)) {
// If the widget is outside visible screen
pos = appPos;
pos += offsetWidget();
}
}
return pos;
}
示例4: update_screen_combo
int CaptureDialog::update_screen_combo(void)
{
//disable signals
screen_combo->blockSignals(true);
//save current value
int current = screen_combo->currentIndex();
//update combo
QStringList list;
screen_combo->clear();
QDesktopWidget * desktop = QApplication::desktop();
int screens = desktop->screenCount();
for (int i=0; i<screens; i++)
{
const QRect rect = desktop->screenGeometry(i);
list.append(QString("Screen %1 [%2x%3]").arg(i).arg(rect.width()).arg(rect.height()));
}
screen_combo->addItems(list);
//set current value
int saved_value = APP->config.value("capture/projector_screen", 1).toInt();
int default_screen = (saved_value<screen_combo->count() ? saved_value : 0);
screen_combo->setCurrentIndex((-1<current && current<screen_combo->count() ? current : default_screen));
//enable signals
screen_combo->blockSignals(false);
return screen_combo->count();
}
示例5: fillScreens
void PCDMgui::fillScreens(){
//Set a background image on any other available screens
QDesktopWidget *DE = QApplication::desktop();
screens.clear();
//Generate the background style sheet
//QString tmpIcon = currentTheme->itemIcon("background");
//if( tmpIcon.isEmpty() || !QFile::exists(tmpIcon) ){ tmpIcon = ":/images/backgroundimage.jpg"; }
//QString bgstyle = "QWidget#BGSCREEN{border-image: url(BGIMAGE) stretch;}";
//bgstyle.replace("BGIMAGE", tmpIcon);
//this->setStyleSheet(bgstyle);
//Now apply the background to all the other screens
// - Keep track of the total width/height of all screens combined (need to set the QMainWindow to this size)
int wid, high;
wid = high = 0;
for(int i=0; i<DE->screenCount(); i++){
//if(i != DE->screenNumber(this)){
//Just show a generic QWidget with the proper background image on every screen
QWidget *screen = new QWidget(this->centralWidget());
screen->setObjectName("BGSCREEN");
QRect rec = DE->screenGeometry(i);
screen->setGeometry( rec );
if(rec.height() > high){ high = rec.height(); }
wid += rec.width();
//screen->setStyleSheet(bgstyle);
screen->show();
screens << screen;
/*}else{
//Now move the mouse cursor over this window (fix for multi-monitor setups)
QCursor::setPos( DE->screenGeometry(i).center() );
}*/
}
this->setGeometry(0,0,wid,high);
this->activateWindow();
QCursor::setPos( DE->screenGeometry(0).center() );
}
示例6: update_screen_combo
int CalibrationDialog::update_screen_combo(void)//更新投影仪屏幕分辨率的选项
{
//disable signals
screen_combo->blockSignals(true);//禁止screen_combo接收信号
//save current value
int current = screen_combo->currentIndex();//得到现在所选的屏幕
//update combo
QStringList list;//存储的是显示器都有哪些可用,及其分辨率大小
screen_combo->clear();
QDesktopWidget * desktop = QApplication::desktop();
int screens = desktop->screenCount();//统计有多少个桌面,有多少个屏幕可用
for (int i=0; i<screens; i++)
{
const QRect rect = desktop->screenGeometry(i);//屏幕几何大小(分辨率)
list.append(QString("Screen %1 [%2x%3]").arg(i).arg(rect.width()).arg(rect.height()));//显示屏幕的分辨率Screen 0[1920*1080]
}
screen_combo->addItems(list);
//set current value
int saved_value = 1;
int default_screen = (saved_value<screen_combo->count() ? saved_value : 0);//默认的选择屏幕号为0,否则为saved_value
screen_combo->setCurrentIndex((-1<current && current<screen_combo->count() ? current : default_screen));//从所选的屏幕和默认的屏幕中决定是哪一个
//enable signals
screen_combo->blockSignals(false);
return screen_combo->count();//返回屏幕的个数(总数)
}
示例7: QDialog
ConfigureDialog::ConfigureDialog(QSettings *settings, QWidget *parent) :
QDialog(parent),
ui(new Ui::ConfigureDialog),
mSettings(settings),
mOldSettings(new RazorSettingsCache(settings))
{
ui->setupUi(this);
connect(ui->buttonBox->button(QDialogButtonBox::Reset), SIGNAL(clicked()), this, SLOT(resetSettings()));
// Position .................................
ui->positionCbx->addItem(tr("Top edge of screen"), QVariant(ConfigureDialog::PositionTop));
ui->positionCbx->addItem(tr("Center of screen"), QVariant(ConfigureDialog::PositionCenter));
connect(ui->positionCbx, SIGNAL(currentIndexChanged(int)), this, SLOT(positionCbxChanged(int)));
// Monitor ..................................
QDesktopWidget *desktop = qApp->desktop();
ui->monitorCbx->addItem(tr("Monitor where the mouse"), QVariant(0));
int monCnt = desktop->screenCount();
for (int i=0; i<monCnt; ++i)
{
ui->monitorCbx->addItem(tr("Always on %1 monitor").arg(i+1), QVariant(i+1));
}
ui->monitorCbx->setEnabled(monCnt > 1);
connect(ui->monitorCbx, SIGNAL(currentIndexChanged(int)), this, SLOT(monitorCbxChanged(int)));
// Shortcut .................................
connect(ui->shortcutEd, SIGNAL(keySequenceChanged(QString)), this, SLOT(shortcutChanged(QString)));
settingsChanged();
}
示例8: shootScreen
void MainWindowActions::shootScreen()
{
QDesktopWidget* desktop = qApp->desktop();
QList<QScreen*> screens = qApp->screens();
for (int i=0; i<desktop->screenCount(); ++i)
{
QWidget* screenWidget = desktop->screen(i);
WId screenWinId = screenWidget->winId();
QRect geo = desktop->screenGeometry(i);
QString name = "";
if (desktop->screenCount()>1)
name = screens[i]->name().split(" ").join("");
this->saveScreenShot(screens[i]->grabWindow(screenWinId, geo.left(), geo.top(), geo.width(), geo.height()), name);
}
}
示例9: main
int main(int argc,char * argv[])
{
QApplication app(argc,argv);
QDesktopWidget * desktopWidget = QApplication::desktop();
int screenNum = desktopWidget->screenCount();
if (screenNum == 3)
{
QRect rect;
int i;
Dialog window0;
Dialog window1(&window0);
Dialog window2(&window1);
qDebug()<<"window0 "<<window0.winId();
qDebug()<<"window1 "<<window1.winId();
qDebug()<<"window2 "<<window2.winId();
for (i=0;i<screenNum;i++)
{
rect = desktopWidget->screenGeometry(i);
qDebug()<<i<<" "<<rect;
switch(rect.width())
{
case SCREEN0:
{
window0.move(rect.topLeft());
window0.resize(rect.width(),rect.height());
break;
}
case SCREEN1:
{
window1.move(rect.topLeft());
window1.resize(rect.width(),rect.height());
break;
}
case SCREEN2:
{
window2.move(rect.topLeft());
window2.resize(rect.width(),rect.height());
break;
}
}
}
window0.show();
window1.show();
window2.show();
window2.startTimer();
return app.exec();
}
}
示例10: getSecondMonitorGeometry
cv::Rect* getSecondMonitorGeometry() {
QDesktopWidget* desktop = QApplication::desktop();
// Return last monitor geometry
return getMonitorGeometryByIndex(desktop->screenCount()-1);
// For replaying experiment videos, return false geometry for 1920x1080 monitor
//return new cv::Rect(0, 0, 1280, 777);
}
示例11: loadScreens
void ScreensModel::loadScreens()
{
beginResetModel();
m_screens.clear();
QDesktopWidget *dw = QApplication::desktop();
for (int i=0;i<dw->screenCount();i++) {
m_screens.append(dw->screenGeometry(i));
}
endResetModel();
}
示例12: rect_on_screen
bool rect_on_screen(const QRect &rect)
{
QDesktopWidget *desktop = qApp->desktop();
for (int i = 0; i < desktop->screenCount(); i++) {
if (desktop->availableGeometry(i).contains(rect))
return true;
}
return false;
}
示例13: main
int main(int argc, char ** argv)
{
//Setup any pre-QApplication initialization values
LXDG::setEnvironmentVars();
setenv("DESKTOP_SESSION","LUMINA",1);
setenv("XDG_CURRENT_DESKTOP","LUMINA",1);
//Check is this is the first run
bool firstrun = false;
if(!QFile::exists(logfile.fileName())){ firstrun = true; }
//Setup the log file
qDebug() << "Lumina Log File:" << logfile.fileName();
if(logfile.exists()){ logfile.remove(); } //remove any old one
//Make sure the parent directory exists
if(!QFile::exists(QDir::homePath()+"/.lumina/logs")){
QDir dir;
dir.mkpath(QDir::homePath()+"/.lumina/logs");
}
logfile.open(QIODevice::WriteOnly | QIODevice::Append);
//Startup the Application
LSession a(argc, argv);
//Setup Log File
qInstallMsgHandler(MessageOutput);
//Setup the QSettings
QSettings::setPath(QSettings::NativeFormat, QSettings::UserScope, QDir::homePath()+"/.lumina/settings");
qDebug() << "Initializing Lumina";
//Start up the Window Manager
qDebug() << " - Start Window Manager";
WMProcess WM;
WM.startWM();
QObject::connect(&WM, SIGNAL(WMShutdown()), &a, SLOT(closeAllWindows()) );
//Load the initial translations
QTranslator translator;
QLocale mylocale;
QString langCode = mylocale.name();
if ( ! QFile::exists(PREFIX + "/share/Lumina-DE/i18n/lumina-desktop_" + langCode + ".qm" ) ) langCode.truncate(langCode.indexOf("_"));
translator.load( QString("lumina-desktop_") + langCode, PREFIX + "/share/Lumina-DE/i18n/" );
a.installTranslator( &translator );
qDebug() << "Locale:" << langCode;
//Now start the desktop
QDesktopWidget DW;
QList<LDesktop*> screens;
for(int i=0; i<DW.screenCount(); i++){
qDebug() << " - Start Desktop " << i;
screens << new LDesktop(i);
a.processEvents();
}
qDebug() << " --exec";
int retCode = a.exec();
qDebug() << "Stopping the window manager";
WM.stopWM();
qDebug() << "Finished Closing Down Lumina";
logfile.close();
return retCode;
}
示例14: pixmap
RazorDeskManager::RazorDeskManager(const QString & configId, RazorSettings * config)
: DesktopPlugin(configId, config)
{
m_launchMode = DesktopPlugin::launchModeFromString(config->value("icon-launch-mode").toString());
config->beginGroup(configId);
bool makeIcons = config->value("icons", false).toBool();
//now we got the desktop we need to determine if the user wants a defined picture there
QString finalPixmap = config->value("wallpaper", "").toString();
config->endGroup();
if (finalPixmap.isEmpty() || !QFile::exists(finalPixmap))
{
//now we want to use the system default - we still need to find that one out though
finalPixmap = razorTheme.desktopBackground();
qDebug() << "trying to get system-defaults" << finalPixmap;
}
if (! finalPixmap.isEmpty())
{
qDebug() << "Creating wallpaper";
int width,height;
QDesktopWidget * dw = QApplication::desktop();
if (dw->screenCount() == 1)
{
width=dw->width();
height = dw->height();
}
else
{
width=dw->screenGeometry(-1).width();
height=dw->screenGeometry(-1).height();
}
QPixmap pixmap(finalPixmap);
pixmap = pixmap.scaled(width,height);
Pixmap p = pixmap.handle();
XGrabServer(QX11Info::display());
XChangeProperty(QX11Info::display(), QX11Info::appRootWindow(), XfitMan::atom("_XROOTPMAP_ID"), XA_PIXMAP, 32, PropModeReplace, (unsigned char *) &p, 1);
XChangeProperty(QX11Info::display(), QX11Info::appRootWindow(), XfitMan::atom("ESETROOT_PMAP_ID"), XA_PIXMAP, 32, PropModeReplace, (unsigned char *) &p, 1);
XSetCloseDownMode(QX11Info::display(), RetainPermanent);
XSetWindowBackgroundPixmap(QX11Info::display(), QX11Info::appRootWindow(), p);
XClearWindow(QX11Info::display(), QX11Info::appRootWindow());
XUngrabServer(QX11Info::display());
XFlush(QX11Info::display());
}
if (makeIcons)
{
deskicons = new RazorSettings("deskicons", this);
m_fsw = new QFileSystemWatcher(QStringList() << QDesktopServices::storageLocation(QDesktopServices::DesktopLocation), this);
connect(m_fsw, SIGNAL(directoryChanged(const QString&)), this, SLOT(updateIconList()));
updateIconList();
}
}
示例15: main
int main(int argc, char *argv[])
{
QApplication::setAttribute(Qt::AA_UseOpenGLES,true);
QApplication a(argc, argv);
// MODEL
SubteState * m_subte = new SubteState();
// CONTROLLER DISPATCHER
EventHandler *m_eventHandler = new EventHandler();
// VIEWS
BoardCenter * m_c = new BoardCenter(0);
BoardAtp *m_a = new BoardAtp(0);
BoardMac *m_m = new BoardMac(0,m_subte,m_eventHandler);
BoardBottom *m_b = new BoardBottom(0);
BoardHardware *m_h = new BoardHardware(0,m_subte,m_eventHandler);
QTabWidget *m_tabs = new QTabWidget(0);
m_tabs->addTab(m_h,QObject::tr("HARDWARE"));
m_tabs->addTab(m_b,QObject::tr("BOTTOM"));
m_tabs->setMinimumWidth(1024);
m_tabs->setMinimumHeight(768);
QDesktopWidget *desktop = a.desktop();
if(desktop->screenCount() == 4){
QRect s0 = desktop->screenGeometry(0);
QRect s1 = desktop->screenGeometry(1);
QRect s2 = desktop->screenGeometry(2);
QRect s3 = desktop->screenGeometry(3);
m_c->showFullScreen();
m_a->showFullScreen();
m_m->showFullScreen();
m_tabs->showFullScreen();
m_c->move(s0.topLeft());
m_a->move(s2.topLeft());
m_m->move(s3.topLeft());
m_tabs->move(s1.topLeft());
}else{
m_c->showNormal();
m_a->showNormal();
m_m->showNormal();
m_tabs->showNormal();
}
m_eventHandler->setModel(m_subte);
m_subte->setHandler(m_eventHandler);
m_eventHandler->initConnection(qApp->applicationDirPath());
QObject::connect(m_eventHandler,SIGNAL(closeApp()),qApp,SLOT(quit()));
return a.exec();
}