当前位置: 首页>>代码示例>>C++>>正文


C++ QDesktopWidget类代码示例

本文整理汇总了C++中QDesktopWidget的典型用法代码示例。如果您正苦于以下问题:C++ QDesktopWidget类的具体用法?C++ QDesktopWidget怎么用?C++ QDesktopWidget使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QDesktopWidget类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setMouseTracking

LapUSMainWindow::LapUSMainWindow(mtsIntuitiveDaVinci *daVinci,svlFilterImageOpenGLQtWidget *USVideoWidget,svlFilterImageFileWriter &USimagewriter1,svlFilterImageFileWriter &Liveimagewriter1,string saveFolderPath)
{
	clicked = false ;
	released = false;
//	int argc = 0;
//	char **argv;
//	QApplication app(argc, argv);
	this->daVinci = daVinci;
	this->saveFolderPath = saveFolderPath;
	this->setWindowState(Qt::WindowFullScreen);
	setMouseTracking(true);
	count = 1;
	USimagewriter = &USimagewriter1;
	Liveimagewriter = &Liveimagewriter1;
	std::cout<<"Creating the main window......\n";
	/* -------------Create the browser tabs -----------------*/
	browserWidget = new BrowserWidget(this);

	/*--------------Create the US + Real Image Viewer-------*/
	USviewerWidget = new USViewer(this);

	/*-------------Create the preop image viewer -------*/
	preopViewerWidget = new PreopViewer(this);

	/* Create the LapUS mouse */
//	mouse = new LapUSMouse(daVinci); 

    //this->setStyleSheet("background-color:black;");


	/*-------------- Create the video widget ------------------*/

	QHBoxLayout* videoLayout = new QHBoxLayout();//(QBoxLayout::LeftToRight);
	videoLayout->setMargin(0);
	videoLayout->setSpacing(0);
	//videoLayout->addWidget(USVideoWidget,4,Qt::AlignCenter);
	videoLayout->addWidget(USVideoWidget,4);
	//USVideoWidget->setFixedSzie(400,400);

	// contains the video and the save button
	videoWidget = new QWidget();
	videoWidget->setParent(this);
//	videoWidget->setFixedSize(380,380);
	//videoWidget->setFixedSize(400,380);

	//QPushButton * Save = new QPushButton();
	Save = new QPushButton();
	Save->setFixedSize(120,50);
	Save->setText("Save");
	connect(Save,SIGNAL(clicked()),this,SLOT(saveImages()));
	Save->setStyleSheet("QPushButton { background-color:gray; font-size: 14pt}");//" qlineargradientx1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #f6f7fa, stop: 1 #dadbde}");
 
	videoWidget->setLayout(videoLayout);

	justWidget = new QWidget();
	//QVBoxLayout* ll = new QVBoxLayout();
	QHBoxLayout* ll = new QHBoxLayout();
	ll->addWidget(videoWidget);
	ll->addWidget(Save,0,Qt::AlignRight | Qt::AlignVCenter);
	justWidget->setLayout(ll);
	ll->setMargin(0);
	ll->setSpacing(0);


	// QWidget* justWidget = new QWidget();
	// QVBoxLayout* ll = new QVBoxLayout();
	// ll->addWidget(videoWidget);
	// ll->addWidget(Save,0,Qt::AlignBottom | Qt::AlignHCenter);
	// justWidget->setLayout(ll);

	//	videoWidget->show();
	//videoWidget->setMinimumSize(400,400);
	//videoWidget->setGeometry(0,0,350,350);
	//videoWidget->setFixedSize(350,350);  // TODO set it up according to the screen size 
	/*-------------- Create a the left widget containing the video , USViewer and preop ------------------*/


	QDesktopWidget *desk = QApplication::desktop();
//	QRect screenSize;
	if(desk)
     	screenSize = desk->screenGeometry(0);

    std::cout<<"Printing the screen geometry x :";
    std::cout<<screenSize.x() <<"y : "<<screenSize.y();
    std::cout<<"\n";

//	USviewerWidget->hide();
	preopViewerWidget->hide();
	//videoWidget->show();
	//videoWidget->setFixedSize(400,400);


	// QSizePolicy sizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
	// sizePolicy.setHeightForWidth(true);
	// videoWidget->setSizePolicy(sizePolicy);

	/* add the video widget , USviewer and the preopview in a layout*/
    // QGridLayout *leftLayout = new QGridLayout();
    // leftLayout->addWidget(videoWidget,0,0);
    // leftLayout->addWidget(USviewerWidget,1,0);
//.........这里部分代码省略.........
开发者ID:vineetak,项目名称:LapUSProject,代码行数:101,代码来源:LapUSMainWindow.cpp

示例2: desktopCenter

QPoint StatusDialog::desktopCenter()
{
  QDesktopWidget desktop;
  return QPoint(desktop.width() / 2 - size().width() / 2, desktop.height() / 2 - size().height() / 2);
}
开发者ID:RankoR,项目名称:mqutim,代码行数:5,代码来源:statusdialog.cpp

示例3: validHtml

QString validHtml(const QString &html, bool allowReplacement, QTextCursor *tc)
	{
	QDesktopWidget dw;
	ValidDocument oValidDocument(allowReplacement);

	QRectF qr = dw.availableGeometry();
	oValidDocument.setTextWidth(qr.width() / 2);
	oValidDocument.setDefaultStyleSheet(qApp->styleSheet());

	oValidDocument.setHtml(html);
	bool fIsValid = oValidDocument.isValid();

	QStringList qslAllowed = allowedSchemes();
	for (QTextBlock qtb = oValidDocument.begin(); qtb != oValidDocument.end(); qtb = qtb.next())
		{
		for (QTextBlock::iterator qtbi = qtb.begin(); qtbi != qtb.end(); ++qtbi)
			{
			const QTextFragment &qtf = qtbi.fragment();
			QTextCharFormat qcf = qtf.charFormat();
			if (! qcf.anchorHref().isEmpty())
				{
				QUrl url(qcf.anchorHref());
				if (! url.isValid() || ! qslAllowed.contains(url.scheme()))
					{
					QTextCharFormat qcfn = QTextCharFormat();
					QTextCursor qtc(&oValidDocument);
					qtc.setPosition(qtf.position(), QTextCursor::MoveAnchor);
					qtc.setPosition(qtf.position()+qtf.length(), QTextCursor::KeepAnchor);
					qtc.setCharFormat(qcfn);
					qtbi = qtb.begin();
					}
				}
			if (qcf.isImageFormat())
				{
				QTextImageFormat qtif = qcf.toImageFormat();
				QUrl url(qtif.name());
				if (! qtif.name().isEmpty() && ! url.isValid())
					fIsValid = false;
				}
			}
		}

	oValidDocument.adjustSize();
	QSizeF s = oValidDocument.size();

	if (!fIsValid || (s.width() > qr.width()) || (s.height() > qr.height())) {
		oValidDocument.setPlainText(html);
		oValidDocument.adjustSize();
		s = oValidDocument.size();

		if ((s.width() > qr.width()) || (s.height() > qr.height())) {
			QString errorMessage = "[[ Text object too large to display ]]";
			if (tc) {
				tc->insertText(errorMessage);
				return QString();
			} else {
				return errorMessage;
			}
		}
	}

	if (tc) {
		QTextCursor tcNew(&oValidDocument);
		tcNew.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
		tc->insertFragment(tcNew.selection());
		return QString();
	} else {
		return oValidDocument.toHtml();
	}
}
开发者ID:voodoo-chile,项目名称:Cambrian-src,代码行数:70,代码来源:WChatLog.cpp

示例4: QMainWindow

MainPage::MainPage(QWidget *parent, Qt::WFlags flags)
    : QMainWindow(parent, flags)
{   
     ui.setupUi(this);

     this->LoadQSS();

     m_mousePressed = false;

     QObject::connect(ui.toolButtonHardware, SIGNAL(clicked()), this, SLOT(HardwareInforClicked()));
     QObject::connect(ui.toolButtonTempManagement, SIGNAL(clicked()), this, SLOT(TemperatureClicked()));
     QObject::connect(ui.toolButtonTestItem, SIGNAL(clicked()), this, SLOT(TestItemClicked()));

     QObject::connect(ui.pushButtonMin, SIGNAL(clicked()), this, SLOT(MinButtonClicked()));
     QObject::connect(ui.pushButtonClose, SIGNAL(clicked()), this, SLOT(CloseButtonClicked()));
     QObject::connect(ui.pushButtonUpdate, SIGNAL(clicked()), this, SLOT(UpdateButtonClicked()));

     QObject::connect(&m_checkNewTimer, SIGNAL(timeout()), this, SLOT(CheckNewTimerTimeout()));
     QObject::connect(&m_downloadNewTimer, SIGNAL(timeout()), this, SLOT(DownloadNewTimerTimeout()));

     // 隐藏默认窗口边框和标题栏
     this->setWindowFlags(Qt::Window|Qt::FramelessWindowHint|Qt::WindowSystemMenuHint
         |Qt::WindowMinimizeButtonHint|Qt::WindowMaximizeButtonHint);

     this->setWindowIcon(QIcon(":/ControlImage/Main.png"));

     QString title = MAIN_TITLE;
     title += LAppParam::GetAppVersion();
     this->ui.labelTitle->setText(title);

     this->ui.pushButtonUpdate->setVisible(false);

    // 获取当前系统DPI, 当前系统DPI除以设计时DPI值, 则得到UI放大系数
    const float DESIGN_DPI = 96.0f; // 设计时DPI
    QPainter painter(this);
    QPaintDevice* pDevice = painter.device();
    PrintLogW(L"System DPI X: %d, Y: %d", pDevice->logicalDpiX(), pDevice->logicalDpiY());
    float ratioX = pDevice->logicalDpiX()/DESIGN_DPI;
    float ratioY = pDevice->logicalDpiY()/DESIGN_DPI;
    m_uiRatio = ratioX > ratioY ? ratioX : ratioY;
    if (m_uiRatio < 1.0f)
        m_uiRatio = 1.0f;
    PrintLogW(L"UI Ratio: %f", m_uiRatio);

    // 根据比例重新调整主UI大小, 并居中显示
    int width = this->geometry().width() * m_uiRatio;
    int height = this->geometry().height() * m_uiRatio;
    this->setFixedSize(width, height);
    QDesktopWidget* pDesk = QApplication::desktop();
    this->move((pDesk->width() - width) / 2, (pDesk->height() - height) / 2);

    // 显示启动画面
    QPixmap originalImage(".\\Image\\Background\\splash.png");
    QSize imageSize(originalImage.width() * m_uiRatio, originalImage.height() * m_uiRatio);
    QPixmap scaledImage = originalImage.scaled(imageSize, Qt::KeepAspectRatio);
    QFont splashFont("Microsoft YaHei UI", 10);
    m_splashScreen.setFont(splashFont);
    m_splashScreen.setPixmap(scaledImage);
    m_splashScreen.show();
    
    width = ui.stackedWidget->width() * m_uiRatio;
    height = ui.stackedWidget->height() * m_uiRatio;

    m_splashScreen.showMessage(QObject::tr("Creating Hardware Page..."), Qt::AlignLeft | Qt::AlignTop, Qt::red);
    m_pHardwareInforPage = new HardwareInforPage(m_uiRatio);
    m_pHardwareInforPage->SetSplashScreen(&m_splashScreen);
    m_pHardwareInforPage->setFixedSize(width, height);
    m_pHardwareInforPage->InitHardwareInfor();
    ui.stackedWidget->addWidget(m_pHardwareInforPage);
    
    m_splashScreen.showMessage(QObject::tr("Creating Temperature Page..."), Qt::AlignLeft | Qt::AlignTop, Qt::red);
    m_pTempManagementPage = new TempManagementPage();
    m_pTempManagementPage->setFixedSize(width, height);
    ui.stackedWidget->addWidget(m_pTempManagementPage);

    m_splashScreen.showMessage(QObject::tr("Creating Test Item Page..."), Qt::AlignLeft | Qt::AlignTop, Qt::red);
    m_pTestItemPage = new TestItemPage(m_uiRatio);
    m_pTestItemPage->setFixedSize(width, height);
    ui.stackedWidget->addWidget(m_pTestItemPage);


    if (APP_NORMAL == LAppParam::GetStartMode())
        ui.stackedWidget->setCurrentWidget(m_pHardwareInforPage);
    else if (APP_RESTARTAGING == LAppParam::GetStartMode())
        ui.stackedWidget->setCurrentWidget(m_pTestItemPage);
    else
        ui.stackedWidget->setCurrentWidget(m_pTestItemPage);
    
}
开发者ID:BurnellLiu,项目名称:LiuProject,代码行数:89,代码来源:MainPage.cpp

示例5: get_screen_dpi

double get_screen_dpi()
{
	QDesktopWidget *mydesk = qApp->desktop();
	return mydesk->physicalDpiX();
}
开发者ID:JianchunMei,项目名称:subsurface,代码行数:5,代码来源:subsurface-desktop-helper.cpp

示例6: get_screen_dpi

double get_screen_dpi()
{
	QDesktopWidget *mydesk = application->desktop();
	return mydesk->physicalDpiX();
}
开发者ID:Exhora,项目名称:subsurface,代码行数:5,代码来源:qt-gui.cpp

示例7: pixmap

void PicturePopup::popUp(  const QString & strCaption
						 , long			lTimeToShow
						 , long			lTimeToLive
						 , long			lTimeToHide
						 )
{
	const QPixmap*	pict  = pixmap();
	int				width = pict->width();
	int				height= pict->height();
	resize(width,height);

	m_nSkinHeight	= height;
	m_nSkinWidth	= width;

	unsigned int nDesktopHeight = 0;
	unsigned int nDesktopWidth  = 0;
	unsigned int nScreenWidth   = 0;
	unsigned int nScreenHeight  = 0;
	
	QRect rcDesktop;
	QRect rcScreen;
	m_strCaption	= strCaption;
	m_lTimeToShow	= lTimeToShow;
	m_lTimeToLive	= lTimeToLive;
	m_lTimeToHide	= lTimeToHide;

    QDesktopWidget* desktopWidget = QApplication::desktop();			// get the desktop
	int primaryScreen = desktopWidget->primaryScreen();					// get the primary screen

    rcDesktop		= desktopWidget->availableGeometry(primaryScreen);	// get the desktop rectangle
	rcScreen		= desktopWidget->screenGeometry(primaryScreen);		// get the screen geometry

	nDesktopWidth	= rcDesktop.width();
	nDesktopHeight	= rcDesktop.height();
	nScreenWidth	= rcScreen.width();
	nScreenHeight	= rcScreen.height();

    if(nScreenWidth < 1024)
    {
	    m_nSkinHeight = 100;
	    m_nSkinWidth = 70;
    }
 	bool bTaskbarOnRight	= nDesktopWidth  < nScreenWidth && rcDesktop.left() == 0;
 	bool bTaskbarOnLeft		= nDesktopWidth  < nScreenWidth && rcDesktop.left() != 0;
 	bool bTaskBarOnTop		= nDesktopHeight < nScreenHeight && rcDesktop.top() !=0;

	switch (m_nAnimStatus)
	{
		case IDT_HIDDEN:
			if (bTaskbarOnRight)
			{
				m_lDelayBetweenShowEvents = m_lTimeToShow/(m_nSkinWidth/m_nIncrement);
				m_lDelayBetweenHideEvents = m_lTimeToHide/(m_nSkinWidth/m_nIncrement);
				m_nStartPosX			  = rcDesktop.right();
				m_nStartPosY			  = rcDesktop.bottom() - m_nSkinHeight;
				m_nTaskbarPlacement		  = TASKBAR_ON_RIGHT;
			}
			else if (bTaskbarOnLeft)
			{
				m_lDelayBetweenShowEvents = m_lTimeToShow/(m_nSkinWidth/m_nIncrement);
				m_lDelayBetweenHideEvents = m_lTimeToHide/(m_nSkinWidth/m_nIncrement);
				m_nStartPosX			  = rcDesktop.left() - m_nSkinWidth;
				m_nStartPosY			  = rcDesktop.bottom() - m_nSkinHeight;
				m_nTaskbarPlacement		  = TASKBAR_ON_LEFT;
			}
			else if (bTaskBarOnTop)
			{
				m_lDelayBetweenShowEvents = m_lTimeToShow/(m_nSkinHeight/m_nIncrement);
				m_lDelayBetweenHideEvents = m_lTimeToHide/(m_nSkinHeight/m_nIncrement);
				m_nStartPosX			  = rcDesktop.right() - m_nSkinWidth;
				m_nStartPosY			  = rcDesktop.top() - m_nSkinHeight;
				m_nTaskbarPlacement		  = TASKBAR_ON_TOP;
			}
			else //if (bTaskbarOnBottom)
			{
				// Taskbar is on the bottom or Invisible
                m_nTaskbarHeight		  = nScreenHeight - nDesktopHeight;
				m_lDelayBetweenShowEvents = m_lTimeToShow/(m_nSkinHeight/m_nIncrement);
				m_lDelayBetweenHideEvents = m_lTimeToHide/(m_nSkinHeight/m_nIncrement);
				m_nStartPosX		      = rcDesktop.right() - m_nSkinWidth;
				m_nStartPosY			  = rcDesktop.bottom();
				m_nTaskbarPlacement		  = TASKBAR_ON_BOTTOM;
			}
			m_nCurrentPosX = m_nStartPosX;
			m_nCurrentPosY = m_nStartPosY;
            m_pTimerAppear->start(m_lDelayBetweenShowEvents);
			break;
		case IDT_WAITING:
			repaint();
            m_pTimerWait->stop();
			m_pTimerWait->setSingleShot(true);
            m_pTimerWait->start(m_lTimeToLive);
			break;
		case IDT_APPEARING:
			repaint();
			break;
		case IDT_DISAPPEARING:
            m_pTimerDisappear->stop();
			m_pTimerWait->setSingleShot(true);
            m_pTimerWait->start(m_lTimeToLive);
//.........这里部分代码省略.........
开发者ID:12019,项目名称:svn.gov.pt,代码行数:101,代码来源:picturepopup.cpp

示例8: QMainWindow

EtaKeyboard::EtaKeyboard(QWidget *parent)
    : QMainWindow(parent)
{
    setWindowFlags(Qt::WindowStaysOnTopHint |
                   Qt::FramelessWindowHint |
                   Qt::WindowSystemMenuHint |
                   Qt::WindowDoesNotAcceptFocus |
                   Qt::X11BypassWindowManagerHint);

    QDesktopWidget dw;
    screenWidth = dw.screenGeometry(dw.primaryScreen()).width();
    screenHeight = dw.screenGeometry(dw.primaryScreen()).height();

    key_height = screenHeight / 16;
    key_width = screenWidth / 26;
    dock_height = screenHeight / 30;
    m_width = 13*key_width;
    m_height = key_height*4+dock_height;

    configpath = QDir::homePath() + "/.config/etak/config.ini";
    color = "gray";
    Settings::setLanguage("trq");
    Settings::setAutoShowBool(true);

    QFileInfo checkConfig(configpath);

    if (checkConfig.exists() && checkConfig.isFile()) {
        preferences = new QSettings(configpath,QSettings::IniFormat);
        preferences->beginGroup("etak");
        Settings::setLanguage(preferences->value("Language").toString());
        color= preferences->value("Color").toString();
        Settings::setAutoShowBool(preferences->value("AutoShow").toBool());
        preferences->endGroup();
    }

    Settings::setColors(color); // 'blue' or 'gray'
    Helpers::langChange(Settings::getLanguage()); // intialization of X keyboard layout as trq



    setStyleSheet("background-color: "+Settings::getBackgroundColor()+";");

    setGeometry(screenWidth/2+m_width,0,m_width,0);



    out = LabelInstance::Instance();  // Output text right up to keyboard
    out->setParent(this);
    out->setGeometry(0,0,m_width,dock_height);
    out->setStyleSheet("QLabel{color: white; qproperty-alignment: AlignCenter;}");
    QFont f;
    f.setPointSize(key_height / 5);
    out->setFont(f);


    settingsRectangle = new QDialog(this,Qt::X11BypassWindowManagerHint);
    settingsRectangle->setStyleSheet("background-color: "+Settings::getBackgroundColor()+";");
    settingsRectangle->hide();

    toggleAuto = new QPushButton(settingsRectangle);
    toggleAuto->setGeometry(0,0,key_width*2,dock_height);
    toggleAuto->setCheckable(true);
    toggleAuto->setChecked(Settings::getAutoShowBool());
    if(Settings::getAutoShowBool()) {
        toggleAuto->setText(QString::fromUtf8("Otomatik çıkma : Kapat"));
    } else {
        toggleAuto->setText(QString::fromUtf8("Otomatik çıkma : Aç"));
    }
    toggleAuto->setStyleSheet(Settings::getStyleSheet()+Settings::getStyleSheetExtra());
    QFont g;
    g.setPointSize(key_height / 9);
    toggleAuto->setFont(g);

    connect(toggleAuto,SIGNAL(clicked()),this,SLOT(toggleAutoShow()));

    passwordButton = new QPushButton(this);
    passwordButton->setGeometry(1,1,dock_height,dock_height);
    passwordButton->setStyleSheet(Settings::getStyleSheet()+Settings::getStyleSheetExtra());
    passwordButton->setCheckable(true);
    passwordButton->setChecked(false);
    passwordButton->setText("P");
    g.setBold(true);
    g.setPointSize(key_height/4);
    passwordButton->setFont(g);
    QRegion *region = new QRegion(*(new QRect(passwordButton->x()+2,passwordButton->y()+2,dock_height-6,dock_height-6)),QRegion::Ellipse);
    passwordButton->setMask(*region);
    connect(passwordButton,SIGNAL(clicked()),this,SLOT(togglePassword()));


    QHash<int, QList<unsigned int> > hash;
    QList<unsigned int> listtmp;
    for ( int i = 24 ; i < 36 ; ++i) {
        listtmp.append(i);
    }
    hash.insert(1,listtmp);
    listtmp.clear();
    for ( int j = 38 ; j < 49 ; ++j) {
        listtmp.append(j);
    }
    hash.insert(2,listtmp);
//.........这里部分代码省略.........
开发者ID:Pardus-Kurumsal,项目名称:etak,代码行数:101,代码来源:etakeyboard.cpp

示例9: TestWidget

void tst_orientationchange::resizeEventOnOrientationChange()
{
    // This will test that when orientation 'changes', then
    // at most one resize event is generated.

    TestWidget *normalWidget = new TestWidget();
    TestWidget *fullScreenWidget = new TestWidget();
    TestWidget *maximizedWidget = new TestWidget();

    fullScreenWidget->showFullScreen();
    maximizedWidget->showMaximized();
    normalWidget->show();

    QCoreApplication::sendPostedEvents();
    QCoreApplication::sendPostedEvents();

    QCOMPARE(fullScreenWidget->resizeEventCount, 1);
    QCOMPARE(fullScreenWidget->size(), fullScreenWidget->resizeEventSize);
    QCOMPARE(maximizedWidget->resizeEventCount, 1);
    QCOMPARE(maximizedWidget->size(), maximizedWidget->resizeEventSize);
    QCOMPARE(normalWidget->resizeEventCount, 1);
    QCOMPARE(normalWidget->size(), normalWidget->resizeEventSize);

    fullScreenWidget->reset();
    maximizedWidget->reset();
    normalWidget->reset();

    // Assumes that Qt application is AVKON application.
    CAknAppUi *appUi = static_cast<CAknAppUi*>(CEikonEnv::Static()->EikAppUi());

    // Determine 'opposite' orientation to the current orientation.

    CAknAppUi::TAppUiOrientation orientation = CAknAppUi::EAppUiOrientationLandscape;
    if (fullScreenWidget->size().width() > fullScreenWidget->size().height()) {
        orientation = CAknAppUi::EAppUiOrientationPortrait;
    }

    TRAPD(err, appUi->SetOrientationL(orientation));

    QCoreApplication::sendPostedEvents();
    QCoreApplication::sendPostedEvents();

    // setOrientationL is not guaranteed to change orientation
    // (if emulator configured to support just portrait or landscape, then
    //  setOrientationL call shouldn't do anything).
    // So let's ensure that we do not get resize event twice.

    QVERIFY(fullScreenWidget->resizeEventCount <= 1);
    if (fullScreenWidget->resizeEventCount) {
        QCOMPARE(fullScreenWidget->size(), fullScreenWidget->resizeEventSize);
    }
    QVERIFY(maximizedWidget->resizeEventCount <= 1);
    if (fullScreenWidget->resizeEventCount) {
        QCOMPARE(maximizedWidget->size(), maximizedWidget->resizeEventSize);
    }
    QCOMPARE(normalWidget->resizeEventCount, 0);

    QDesktopWidget desktop;
    QRect qtAvail = desktop.availableGeometry(normalWidget);
    TRect clientRect = static_cast<CEikAppUi*>(CCoeEnv::Static()-> AppUi())->ClientRect();
    QRect symbianAvail = qt_TRect2QRect(clientRect);
    QCOMPARE(qtAvail, symbianAvail);

    // Switch orientation back to original
    orientation = orientation == CAknAppUi::EAppUiOrientationPortrait
                                 ? CAknAppUi::EAppUiOrientationLandscape
                                 : CAknAppUi::EAppUiOrientationPortrait;


    fullScreenWidget->reset();
    maximizedWidget->reset();
    normalWidget->reset();

    TRAP(err, appUi->SetOrientationL(orientation));

    QCoreApplication::sendPostedEvents();
    QCoreApplication::sendPostedEvents();

    // setOrientationL is not guaranteed to change orientation
    // (if emulator configured to support just portrait or landscape, then
    //  setOrientationL call shouldn't do anything).
    // So let's ensure that we do not get resize event twice.

    QVERIFY(fullScreenWidget->resizeEventCount <= 1);
    if (fullScreenWidget->resizeEventCount) {
        QCOMPARE(fullScreenWidget->size(), fullScreenWidget->resizeEventSize);
    }
    QVERIFY(maximizedWidget->resizeEventCount <= 1);
    if (fullScreenWidget->resizeEventCount) {
        QCOMPARE(maximizedWidget->size(), maximizedWidget->resizeEventSize);
    }
    QCOMPARE(normalWidget->resizeEventCount, 0);

    qtAvail = desktop.availableGeometry(normalWidget);
    clientRect = static_cast<CEikAppUi*>(CCoeEnv::Static()-> AppUi())->ClientRect();
    symbianAvail = qt_TRect2QRect(clientRect);
    QCOMPARE(qtAvail, symbianAvail);

    TRAP(err, appUi->SetOrientationL(CAknAppUi::EAppUiOrientationUnspecified));

//.........这里部分代码省略.........
开发者ID:mpvader,项目名称:qt,代码行数:101,代码来源:tst_orientationchange.cpp

示例10: QPixmap

QT_BEGIN_NAMESPACE

QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h)
{
    QWidget *widget = QWidget::find(window);
    if (!widget)
        return QPixmap();

    QRect grabRect = widget->frameGeometry();
    if (!widget->isWindow())
        grabRect.translate(widget->parentWidget()->mapToGlobal(QPoint()));
    if (w < 0)
        w = widget->width() - x;
    if (h < 0)
        h = widget->height() - y;
    grabRect &= QRect(x, y, w, h).translated(widget->mapToGlobal(QPoint()));

    QScreen *screen = qt_screen;
    QDesktopWidget *desktop = QApplication::desktop();
    if (!desktop)
        return QPixmap();
    if (desktop->numScreens() > 1) {
        const int screenNo = desktop->screenNumber(widget);
        if (screenNo != -1)
            screen = qt_screen->subScreens().at(screenNo);
        grabRect = grabRect.translated(-screen->region().boundingRect().topLeft());
    }

    if (screen->pixelFormat() == QImage::Format_Invalid) {
        qWarning("QPixmap::grabWindow(): Unable to copy pixels from framebuffer");
        return QPixmap();
    }

    if (screen->isTransformed()) {
        const QSize screenSize(screen->width(), screen->height());
        grabRect = screen->mapToDevice(grabRect, screenSize);
    }

    QWSDisplay::grab(false);
    QPixmap pixmap;
    QImage img(screen->base(),
               screen->deviceWidth(), screen->deviceHeight(),
               screen->linestep(), screen->pixelFormat());
    img = img.copy(grabRect);
    QWSDisplay::ungrab();

    if (screen->isTransformed()) {
        QMatrix matrix;
        switch (screen->transformOrientation()) {
        case 1: matrix.rotate(90); break;
        case 2: matrix.rotate(180); break;
        case 3: matrix.rotate(270); break;
        default: break;
        }
        img = img.transformed(matrix);
    }

    if (screen->pixelType() == QScreen::BGRPixel)
        img = img.rgbSwapped();

    return QPixmap::fromImage(img);
}
开发者ID:phen89,项目名称:rtqt,代码行数:62,代码来源:qpixmap_qws.cpp

示例11: MyWidget


//.........这里部分代码省略.........
	gnomeButGrp = new QButtonGroup;
	gnomePictureOptions.clear();
	// These options are possible
	QStringList picOpts;
	picOpts << "wallpaper";
	picOpts << "centered";
	picOpts << "scaled";
	picOpts << "zoom";
	picOpts << "spanned";
	// Setup radiobuttons, add to layout, to button group and store in QMap
	for(int i = 0; i < picOpts.size(); ++i) {
		CustomRadioButton *chk = new CustomRadioButton(picOpts.at(i));
		if(i == 3) chk->setChecked(true);
		gnomePicOpsLayCenter->addWidget(chk);
		gnomeButGrp->addButton(chk);
		gnomePictureOptions.insert(picOpts.at(i),chk);
	}
	// And center in a horizontal layout
	QHBoxLayout *gnomePicOpsLay = new QHBoxLayout;
	gnomePicOpsLay->addStretch();
	gnomePicOpsLay->addLayout(gnomePicOpsLayCenter);
	gnomePicOpsLay->addStretch();

	// Add label and button layout to central widget layout
	lay->addWidget(gnomePicOpsLabel);
	lay->addLayout(gnomePicOpsLay);



	////// THE FOLLOWING SCREEN SELECT IS USED BY DIFFERENT WMs //////

	QVBoxLayout *wmMonitorLayCenter = new QVBoxLayout;
	wmMonitorSelect.clear();
	QDesktopWidget desk;
	for(int i = 0; i < desk.screenCount(); ++i) {
		CustomCheckBox *mon = new CustomCheckBox(tr("Screen") + QString(" #%1").arg(i));
		mon->setChecked(true);
		wmMonitorLayCenter->addWidget(mon);
		wmMonitorSelect.insert(i,mon);
	}

	QHBoxLayout *wmMonitorLay = new QHBoxLayout;
	wmMonitorLay->addStretch();
	wmMonitorLay->addLayout(wmMonitorLayCenter);
	wmMonitorLay->addStretch();

	wmMonitorLabel = new CustomLabel("<b><span style=\"font-size:12pt\">" + tr("Select Monitors") + "</span></b> " + "<br><br>" + tr("The wallpaper can be set to either of the available monitors (or any combination)."));
	wmMonitorLabel->setWordWrap(true);
	wmMonitorLabel->setMargin(5);

	lay->addWidget(wmMonitorLabel);
	lay->addLayout(wmMonitorLay);



	/////// XFCE SETTINGS /////////////

	QVBoxLayout *xfcePicOpsLayCenter = new QVBoxLayout;

	xfceButGrp = new QButtonGroup;
	xfcePictureOptions.clear();
	QStringList xfcePicOpts;
	xfcePicOpts << "automatic";
	xfcePicOpts << "centered";
	xfcePicOpts << "tiled";
	xfcePicOpts << "spanned";
开发者ID:jG0D,项目名称:groundstation,代码行数:67,代码来源:wallpaper.cpp

示例12: main

int main(int argc, char *argv[])
{
    signal(SIGINT, signalHandler);
    signal(SIGABRT, signalHandler);
    signal(SIGTERM, signalHandler);

    QApplication app(argc, argv);
    app.setOrganizationName("Genera");
#ifdef TEMPO
    app.setApplicationName("Tempo10");
#endif
#ifdef SNACK
    app.setApplicationName("Snack10");
#endif
#ifdef PRESENCIA
    app.setApplicationName("Presencia10");
    Utils::disableLeds();
#endif

    QString appPath = QApplication::applicationDirPath();

    QString configPath = "/mnt/jffs2/app.ini";
    settings = new QSettings(configPath, QSettings::IniFormat);

    QString lang = settings->value("lang", "es").toString();
    DEBUG("Language is: %s.", lang.toStdString().c_str());

    QTextCodec::setCodecForTr(QTextCodec::codecForName("utf8"));
    QTranslator translator;
    if (lang == "es") {
        if (translator.load("app_es.qm", appPath + "/Resources/languages")) {
            app.installTranslator(&translator);
        } else {
            DEBUG("Unable to install app_es.qm translation.");
        }
    } else {
        if (translator.load("app_en.qm", appPath + "/Resources/languages")) {
            app.installTranslator(&translator);
        } else {
            DEBUG("Unable to install app_en.qm translation.");
        }
    }

    DEBUG("****************************************************************************");
    DEBUG("Equipo: %s", settings->value("tipoEquipo").toString().toStdString().c_str());
    DEBUG("NTP IP: %s", settings->value("ntpIP").toString().toStdString().c_str());
    DEBUG("Lang: %s", settings->value("lang").toString().toStdString().c_str());
    DEBUG("Empresa Holding: %s", settings->value("empresaHolding").toString().toStdString().c_str());
    DEBUG("serialEquipo: %s", settings->value("serialEquipo").toString().toStdString().c_str());
    DEBUG("identificadorEquipo: %s", settings->value("identificadorEquipo").toString().toStdString().c_str());
#ifdef PRESENCIA
    DEBUG("Tipo de Equipo: %s", (settings->value("presenciaType").toString() == "In") ? "Entrada" : "Salida");
#endif
    DEBUG("wsIp: %s", settings->value("wsIP").toString().toStdString().c_str());
    DEBUG("wsPort: %s", settings->value("wsPort").toString().toStdString().c_str());
    DEBUG("wsCargaMasivaURL: %s", settings->value("wsCargaMasivaURL").toString().toStdString().c_str());
    DEBUG("wsFirmwareUpdateURL: %s", settings->value("wsFirmwareUpdateURL").toString().toStdString().c_str());
    DEBUG("wsSincronizacionURL: %s", settings->value("wsSincronizacionURL").toString().toStdString().c_str());
    DEBUG("wsVerificaPersonaURL: %s", settings->value("wsVerificaPersonaURL").toString().toStdString().c_str());
    DEBUG("wsEnrollURL: %s", settings->value("wsEnrollURL").toString().toStdString().c_str());
    DEBUG("wsAlarmasURL: %s", settings->value("wsAlarmasURL").toString().toStdString().c_str());
    DEBUG("****************************************************************************");

    int WIDTH = 240;
    int HEIGHT = 320;
    int screenWidth, screenHeight;
    int x, y;

    window = new MainWindow(settings);
    QDesktopWidget *desktop = QApplication::desktop();

    screenWidth = desktop->width();
    screenHeight = desktop->height();

    x = (screenWidth - WIDTH) / 2;
    y = (screenHeight - HEIGHT) / 2;

    window->resize(WIDTH, HEIGHT);
    window->move(x, y);
    window->setWindowOpacity(1.0);
    window->setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint);

    window->showFullScreen();

    int rc = app.exec();

    if (window) {
        DEBUG("MainWindow Flag: %d", window->flag);
        if (window->flag == 500) {
            if (settings) {
                delete settings;
            }
            if (window)   {
                delete window;
            }

            DEBUG("Bye Bye...");
            fflush(stdout);
            fflush(stderr);
            execl("/sbin/reboot", "reboot", NULL);
//.........这里部分代码省略.........
开发者ID:jvillasante,项目名称:linea10,代码行数:101,代码来源:main.cpp

示例13: parseWindow

static void parseWindow(){
    // option defaults
    bool fullScreen = false; // should it be fullscreen?
    bool disabled = false;
    // what size? (default is fit around widgets. Ignored for fullscreen.)
    int width=-1,height=-1; 
    // if set, move the window to a screen of the given dimensions
    int swidth=-1,sheight=-1;
    // title if any
    char title[256];
    // "tab" number - used to generate a shortcut to pull this window
    // to the front
    int number=-1;
    
    title[0]=0;
    int screensetline=-1;
    
    // set this window to not inverse
    ConfigManager::inverse=false;
    
    // get window options
    bool done = false;
    while(!done){
        switch(tok.getnext()){
        case T_OCURLY:
            done = true;
            break;
        case T_TITLE:
            tok.getnextstring(title);
            break;
        case T_NUMBER:
            number = tok.getnextint();
            break;
        case T_INVERSE:
            ConfigManager::inverse=true;
            break;
        case T_FULLSCREEN:
            fullScreen = true;
            break;
        case T_SIZE: // size of window if not fullscreen
            width = tok.getnextint();
            tok.getnextcheck(T_COMMA);
            height = tok.getnextint();
            break;
        case T_SCREEN: // move to a screen of given dimensions
            swidth = tok.getnextint();
            tok.getnextcheck(T_COMMA);
            screensetline = tok.getline();
            sheight = tok.getnextint();
            break;
        case T_DISABLE: // the window is disabled and should be immediately closed
            disabled=true;
            break;
        }
    }
    
    // create a window
    Window *w = getApp()->createWindow();
    if(number>=0)
        getApp()->setWindowKey(number,w);
    ConfigManager::setStyle(w);
    // and parse the contents
    parseContainer(w->centralWidget());
    
    if(*title){
        w->setWindowTitle(title);
    }
    
    // move the window if we want to
    if(swidth>0){
        QDesktopWidget *dt = QApplication::desktop();
        QRect r;
        int i;
        for(i=0;i<dt->screenCount();i++){
            r = dt->screenGeometry(i);
            printf("Found display : %d x %d\n",r.width(),r.height());
            if(r.width() == swidth && r.height()==sheight)
                break;
        }
        if(i==dt->screenCount())
            throw Exception(screensetline).set("could not find display of %d x %d",swidth,sheight);
        w->move(r.topLeft());
    }
    
    
    // finally show the window and resize if required
    if(disabled){
        w->hide(); // marked "disabled" in the config
    } else {
        w->setWindowState(Qt::WindowActive);
        w->raise();
        w->activateWindow();
        if(fullScreen){
            w->showFullScreen();
        } else {
            if(width>0)
                w->resize(width,height);
            w->showNormal();
        }
    }
//.........这里部分代码省略.........
开发者ID:jimfinnis,项目名称:monitor,代码行数:101,代码来源:config.cpp

示例14: GetClosestScreenNumber

int QtWidgetsTweakletImpl::GetClosestScreenNumber(const QRect& r)
{
  QDesktopWidget *desktop = QApplication::desktop();
  return desktop->screenNumber(QPoint(r.x() + r.width()/2, r.y() + r.height()/2));
}
开发者ID:davidvarisano,项目名称:MITK,代码行数:5,代码来源:berryQtWidgetsTweakletImpl.cpp

示例15: ui_companion_qt_init

static void* ui_companion_qt_init(void)
{
   ui_companion_qt_t *handle = (ui_companion_qt_t*)calloc(1, sizeof(*handle));
   MainWindow *mainwindow = NULL;
   QHBoxLayout *browserButtonsHBoxLayout = NULL;
   QVBoxLayout *layout = NULL;
   QVBoxLayout *launchWithWidgetLayout = NULL;
   QHBoxLayout *coreComboBoxLayout = NULL;
   QMenuBar *menu = NULL;
   QDesktopWidget *desktop = NULL;
   QMenu *fileMenu = NULL;
   QMenu *editMenu = NULL;
   QMenu *viewMenu = NULL;
   QMenu *viewClosedDocksMenu = NULL;
   QRect desktopRect;
   QDockWidget *thumbnailDock = NULL;
   QDockWidget *thumbnail2Dock = NULL;
   QDockWidget *thumbnail3Dock = NULL;
   QDockWidget *browserAndPlaylistTabDock = NULL;
   QDockWidget *coreSelectionDock = NULL;
   QTabWidget *browserAndPlaylistTabWidget = NULL;
   QWidget *widget = NULL;
   QWidget *browserWidget = NULL;
   QWidget *playlistWidget = NULL;
   QWidget *coreSelectionWidget = NULL;
   QWidget *launchWithWidget = NULL;
   ThumbnailWidget *thumbnailWidget = NULL;
   ThumbnailWidget *thumbnail2Widget = NULL;
   ThumbnailWidget *thumbnail3Widget = NULL;
   QPushButton *browserDownloadsButton = NULL;
   QPushButton *browserUpButton = NULL;
   QPushButton *browserStartButton = NULL;
   ThumbnailLabel *thumbnail = NULL;
   ThumbnailLabel *thumbnail2 = NULL;
   ThumbnailLabel *thumbnail3 = NULL;
   QAction *editSearchAction = NULL;
   QAction *loadCoreAction = NULL;
   QAction *unloadCoreAction = NULL;
   QAction *exitAction = NULL;
   QComboBox *launchWithComboBox = NULL;
   QSettings *qsettings = NULL;

   if (!handle)
      return NULL;

   handle->app = static_cast<ui_application_qt_t*>(ui_application_qt.initialize());
   handle->window = static_cast<ui_window_qt_t*>(ui_window_qt.init());

   desktop = qApp->desktop();
   desktopRect = desktop->availableGeometry();

   mainwindow = handle->window->qtWindow;

   qsettings = mainwindow->settings();

   mainwindow->resize(qMin(desktopRect.width(), INITIAL_WIDTH), qMin(desktopRect.height(), INITIAL_HEIGHT));
   mainwindow->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, mainwindow->size(), desktopRect));

   mainwindow->setWindowTitle("RetroArch");
   mainwindow->setDockOptions(QMainWindow::AnimatedDocks | QMainWindow::AllowNestedDocks | QMainWindow::AllowTabbedDocks | GROUPED_DRAGGING);

   widget = new QWidget(mainwindow);
   widget->setObjectName("tableWidget");

   layout = new QVBoxLayout();
   layout->addWidget(mainwindow->contentTableWidget());

   widget->setLayout(layout);

   mainwindow->setCentralWidget(widget);

   menu = mainwindow->menuBar();

   fileMenu = menu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_FILE));

   loadCoreAction = fileMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_FILE_LOAD_CORE), mainwindow, SLOT(onLoadCoreClicked()));
   loadCoreAction->setShortcut(QKeySequence("Ctrl+L"));

   unloadCoreAction = fileMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_FILE_UNLOAD_CORE), mainwindow, SLOT(onUnloadCoreMenuAction()));
   unloadCoreAction->setObjectName("unloadCoreAction");
   unloadCoreAction->setEnabled(false);
   unloadCoreAction->setShortcut(QKeySequence("Ctrl+U"));

   exitAction = fileMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_FILE_EXIT), mainwindow, SLOT(close()));
   exitAction->setShortcut(QKeySequence::Quit);

   editMenu = menu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_EDIT));
   editSearchAction = editMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_EDIT_SEARCH), mainwindow->searchLineEdit(), SLOT(setFocus()));
   editSearchAction->setShortcut(QKeySequence::Find);

   viewMenu = menu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW));
   viewClosedDocksMenu = viewMenu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_CLOSED_DOCKS));
   viewClosedDocksMenu->setObjectName("viewClosedDocksMenu");

   QObject::connect(viewClosedDocksMenu, SIGNAL(aboutToShow()), mainwindow, SLOT(onViewClosedDocksAboutToShow()));

   viewMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS), mainwindow->viewOptionsDialog(), SLOT(showDialog()));

   playlistWidget = new QWidget();
   playlistWidget->setLayout(new QVBoxLayout());
//.........这里部分代码省略.........
开发者ID:DoctorGoat,项目名称:RetroArch_LibNX,代码行数:101,代码来源:ui_qt.cpp


注:本文中的QDesktopWidget类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。