本文整理汇总了C++中QDesktopWidget::width方法的典型用法代码示例。如果您正苦于以下问题:C++ QDesktopWidget::width方法的具体用法?C++ QDesktopWidget::width怎么用?C++ QDesktopWidget::width使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDesktopWidget
的用法示例。
在下文中一共展示了QDesktopWidget::width方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: defaultGeometry
QRect ChatWindow::defaultGeometry() const
{
QSize size(0, 400);
int x, y;
x = pos().x();
y = pos().y();
if (m_chatWidget->chat().contacts().count() > 1)
size.setWidth(550);
else
size.setWidth(400);
QDesktopWidget *desk = qApp->desktop();
if ((size.width() + x) > desk->width())
x = desk->width() - size.width() - 50;
if ((size.height() + y) > desk->height())
y = desk->height() - size.height() - 50;
if (x < 50)
x = 50;
if (y < 50)
y = 50;
return QRect(QPoint(x, y), size);
}
示例2: QMainWindow
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow),
proxy(new QSortFilterProxyModel(parent)),
model(new QStandardItemModel(0, 3, parent))
{
// Set the window style.
Qt::WindowFlags flags = windowFlags();
setWindowFlags(flags | Qt::WindowStaysOnTopHint | Qt::ToolTip);
// Center window.
QDesktopWidget *desktop = QApplication::desktop();
int width = desktop->width() * 0.6;
int height = desktop->height() * 0.6;
setFixedSize(width, height);
move((desktop->width() - width) / 2, (desktop->height() - height) / 2);
// Set up system tray.
trayIconMenu = new QMenu(this);
aboutAction = new QAction(tr("&About"), this);
quitAction = new QAction(tr("&Quit"), this);
connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutMain()));
connect(quitAction, SIGNAL(triggered()), this, SLOT(quitMain()));
trayIconMenu->addAction(aboutAction);
trayIconMenu->addAction(quitAction);
trayIcon = new QSystemTrayIcon(this);
trayIcon->setContextMenu(trayIconMenu);
trayIcon->setToolTip(QString("QuickWin"));
trayIcon->setIcon(QIcon("icon.png"));
trayIcon->show();
// Set up UI items.
ui->setupUi(this);
proxy->setSourceModel(model);
ui->winView->setModel(proxy);
proxy->setFilterKeyColumn(1);
ui->winView->setSortingEnabled(true);
ui->winView->sortByColumn(0, Qt::AscendingOrder);
ui->winView->setEditTriggers(QAbstractItemView::NoEditTriggers);
model->setHeaderData(0, Qt::Horizontal, QObject::tr("Number"));
model->setHeaderData(1, Qt::Horizontal, QObject::tr("Title"));
model->setHeaderData(2, Qt::Horizontal, QObject::tr("Executable"));
ui->winView->header()->resizeSection(0, width * 0.08);
ui->winView->header()->resizeSection(1, width * 0.7);
connect(ui->cmdText, SIGNAL(returnPressed()),
this,SLOT(onTextEnter()));
connect(ui->cmdText, SIGNAL(textChanged(const QString &)),
this, SLOT(onTextChanged(const QString &)));
connect(ui->winView, SIGNAL(activated(QModelIndex)),
this, SLOT(onWitemActivate(QModelIndex)));
// Register system-wide hotkey.
HWND hwnd = (HWND)this->winId();
RegisterHotKey(hwnd, 100, MOD_CONTROL | MOD_ALT, VK_SPACE);
updateWinList();
}
示例3: centerWindow
/**
* @brief _centerWindow Centers the mainWindow on the screen.
* @param window The window to be centered.
*/
void centerWindow(MainWindow & window)
{
const qreal WIDTH_FRAC = 0.7;
const qreal HEIGHT_FRAC = 0.9;
QDesktopWidget dw;
int x = dw.width() * WIDTH_FRAC;
int y = dw.height() * HEIGHT_FRAC;
window.resize(x, y);
x = dw.width() * (1.0 - WIDTH_FRAC) / 2.0;
y = dw.height() * (1.0 - HEIGHT_FRAC) / 2.0;
window.move(x,y);
}
示例4: okpressed
void login::okpressed()
{
int WIDTH = 1280;
int HEIGHT = 1024;
int screenWidth;
int screenHeight;
int x, y;
if(ui.userlineEdit->text()=="admin" && ui.passlineEdit_2->text()=="789")
{
QDesktopWidget *desktop = QApplication::desktop();
screenWidth = desktop->width();
screenHeight = desktop->height();
x = (screenWidth - WIDTH) / 2;
y = (screenHeight - HEIGHT) / 2;
mainWindow *m= new mainWindow(this,0);
this->hide();
m->show();
m->move(x,y);
return;
}
if(ui.userlineEdit->text()=="user" && ui.passlineEdit_2->text()=="123")
{
QDesktopWidget *desktop = QApplication::desktop();
screenWidth = desktop->width();
screenHeight = desktop->height();
x = (screenWidth - WIDTH) / 2;
y = (screenHeight - HEIGHT) / 2;
mainWindow *m= new mainWindow(0,1);
m->show();
this->hide();
m->move(x,y);
return;
}
QMessageBox::critical(this, qApp->trUtf8("Προσοχή"), qApp->trUtf8(
"Λάθος στοιχεία χρήστη "));
//return;
}
示例5: main
//Main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
//variables
int posx, posy;
int screenW;
int screenH;
int WIDTH = 500;//monitor size width
int HEIGHT = 500;//monitor size height
QDesktopWidget *desktop = QApplication::desktop();
//get size of monitor
screenW = desktop->width();
screenH = desktop->height();
posx = (screenW - WIDTH) / 2;
posy = (screenH - HEIGHT) / 2;
collision window;
window.setGeometry(posx, posy, WIDTH, HEIGHT);
window.setFixedSize(WIDTH, HEIGHT);
window.setWindowTitle("HUNT");
// window.setStyleSheet("background-image:Image/background.png");
window.show();
return app.exec();
}
示例6: QMainWindow
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QDesktopWidget *desktop = QApplication::desktop();
int screenWidth, width;
int screenHeight, height;
int x, y;
QSize windowSize;
screenWidth = desktop->width(); // get width of screen
screenHeight = desktop->height(); // get height of screen
windowSize = size(); // size of our application window
width = windowSize.width();
height = windowSize.height();
// little computations
x = (screenWidth - width) / 2;
y = (screenHeight - height) / 2;
y -= 50;
// move window to desired coordinates
move ( x, y );
}
示例7: QSlider
QPlayer::QPlayer(QTimer *timer1, QTimer *timer2, QFile *file1)
{
playTimer = timer1;
refreshTimer = timer2;
file = file1;
QDesktopWidget *desktop = new QDesktopWidget;
setWindowTitle("QPlayer");
setGeometry(desktop->width()-100, desktop->height()-60, 220, 25);
xSize = 130;
ySize = 30;
busy = false;
slider = new QSlider(Qt::Horizontal,this);
QPushButton *playButton = new QPushButton(QIcon(":/icons/amarok_play.png"),"");
QPushButton *pauseButton = new QPushButton(QIcon(":/icons/amarok_pause.png"),"");
playButton->setFlat(true);
pauseButton->setFlat(true);
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(playButton);
layout->addWidget(pauseButton);
layout->addWidget(slider);
connect(playButton, SIGNAL(released()), this, SLOT(play() ) );
connect(pauseButton,SIGNAL(released()), this, SLOT(pause()) );
connect(slider,SIGNAL(sliderReleased()), this, SLOT(seekFile()) );
connect(slider,SIGNAL(sliderPressed()), this, SLOT(sliderPress()) );
setLayout(layout);
show();
}
示例8: displayFrame
/*!
* \brief EnlargedFrameWindow::displayFrame displays a frame with the given filename in a pop up window.
*
* \param fileName the name of the file (as a precondition the file must be located in the tmp directory).
*/
void EnlargedFrameWindow::displayFrame(QString fileName)
{
_scene = new QGraphicsScene();
#ifdef WIN32
pix->load("tmp\\" + fileName);
if(pix->isNull())
{
pix->load("tmp/" + fileName);
}
#else
pix->load("tmp/" + fileName);
#endif
// Set up the image
_scene->addPixmap(*pix);
_scene->setSceneRect( pix->rect() );
ui->frameView->setScene(_scene);
ui->frameView->setGeometry(0,0, _scene->width(), _scene->height());
this->setGeometry( this->x(), this->y(), ui->frameView->width(), ui->frameView->height());
// Move the frame to the center of the screen.
QDesktopWidget *desktop = QApplication::desktop();
int x, y;
x = (desktop->width() - this->width()) / 2;
y = (desktop->height() - this->height()) / 2;
y -= 50;
this->move(x, y);
// Display the frame.
ui->frameView->show();
}
示例9: kShow
void kWarningWindow::kShow(int type){
//加载警告种类
//0 ok
//1 error
if (type == 0){
kMusicData::successSound();
windowImage.load("Resources\\image\\warning");
}
else if (type == 1){
kMusicData::errorSound();
windowImage.load("Resources\\image\\warning2");
}
//透明度
setWindowOpacity(1.0);
//动画
timeid = startTimer(40);
update();
//移动到中间
QDesktopWidget* desktop = QApplication::desktop();
move((desktop->width() - 580) / 2, (desktop->height() - 270) / 2);
show();
}
示例10: on_pushButton_clicked
void Forecast::on_pushButton_clicked()
{
QString path;
QDir dir;
path=dir.currentPath();
//Show file select Dialog.
if(select_window!=NULL) {
delete select_window;
}
select_window = new SelectFile();
select_window->init(SWWYL);
QDesktopWidget* desktop = QApplication::desktop();
int x,y;
x=(desktop->width() - select_window->width())/2;
y=(desktop->height() - select_window->height())/2;
select_window->setGeometry(x,y,1,429);
// select_window->setModal(true);
select_window->show();
// MPlayer 播放视频
// QProcess::execute("C:\\MPlayer_Windows\\mplayer\\MPlayer.exe "+path+"\\yubao\\wenyanliu\\nwp_3dvar.mp4");
// QProcess::execute("C:\\wmplayer\\wmplayer.exe "+path+"\\yubao\\wenyanliu\\nwp_3dvar.mp4");
}
示例11: on_pushButton_hyf_clicked
void Forecast::on_pushButton_hyf_clicked()
{
// QString path;
// QDir dir;
// path=dir.currentPath();
// QDir::setCurrent(path+"\\yubao\\hyfm");
// QProcess::startDetached("frontdetect_example.exe");
// QDir::setCurrent(path);
// Show file select Dialog.
if(select_window!=NULL) {
delete select_window;
}
select_window = new SelectFile();
select_window->init(HYFM);
QDesktopWidget* desktop = QApplication::desktop();
int x,y;
x=(desktop->width() - select_window->width())/2;
y=(desktop->height() - select_window->height())/2;
select_window->setGeometry(x,y,1,429);
// select_window->setModal(true) ;
select_window->show();
}
示例12: setupGui
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void DevHelper::setupGui()
{
// Allow internal widgets to update the status bar
connect(filterMaker, SIGNAL(updateStatusBar(QString)), this, SLOT(updateStatusMessage(QString)));
connect(pluginMaker, SIGNAL(updateStatusBar(QString)), this, SLOT(updateStatusMessage(QString)));
//Set window to open at the center of the screen
QDesktopWidget* desktop = QApplication::desktop();
int screenWidth, width;
int screenHeight, height;
int x, y;
QSize windowSize;
screenWidth = desktop->width(); // get width of screen
screenHeight = desktop->height(); // get height of screen
windowSize = size(); // size of application window
width = windowSize.width();
height = windowSize.height();
x = (screenWidth - width) / 2;
y = (screenHeight - height) / 2;
y -= 50;
// move window to desired coordinates
move(x, y);
}
示例13: showEvent
void CSplashDlg::showEvent(QShowEvent* event)
{
QDesktopWidget* desktop = QApplication::desktop();
move((desktop->width() - this->width())/2, (desktop->height() - this->height())/2);
return QWidget::showEvent(event);
}
示例14: playStateChanged
//播放状态改变
void VideoPlayer::playStateChanged(QMediaPlayer::State state)
{
if (state == QMediaPlayer::StoppedState)
{
QDesktopWidget desktop;
this->setGeometry((desktop.width()-WIDTH)/2, (desktop.height()-HEIGHT)/2, WIDTH, HEIGHT);
lab_background->setStyleSheet("border-image: url(:/Images/videoPlayerBg.png);");
videoWidget->hide();
videoContral->playStop();
tbn_openVideoFile->show();
//停止保持屏幕常亮
timerKeepAwake->stop();
//鼠标恢复
hideCursor = false;
}
else if (state == QMediaPlayer::PlayingState)
{
videoWidget->show();
videoWidget->setFocus();
videoContral->setVideoTitle(playlist_list.at(1)->currentMedia().canonicalUrl().fileName());
// videoContral->setVideoTitle(tr("%1").arg(playlist_list.at(1)->currentIndex()));
//设置屏幕常亮
timerKeepAwake->start(58000);
//设置鼠标隐藏
hideCursor = true;
}
}
示例15: metaDataChanged
void VideoPlayer::metaDataChanged()
{
if (player->state() == QMediaPlayer::StoppedState)
{
return;
}
if (this->isFullScreen())
{
return;
}
QSize size = videoWidget->sizeHint();
if (size.width()>0 && size.height()>0)
{
if (size.width()<WIDTH || size.height() <HEIGHT)
{
size = QSize(size.width()*2, size.height()*2);
}
int videoWidth = size.width();
int videoHeight = size.height();
// emit gotVideoSize(size); ///////////////////////////////////////////何用?
QDesktopWidget desktop;
if (videoHeight > desktop.availableGeometry().height())
{
qreal bilv = qreal(videoWidth) / qreal(videoHeight);qDebug() << bilv;
videoHeight = desktop.availableGeometry().height();
videoWidth = videoHeight * bilv;
}
this->setGeometry((desktop.width()-videoWidth)/2, (desktop.availableGeometry().height()-videoHeight)/2, videoWidth, videoHeight);
}
}