QPushButton *quitScreenshotButton = new QPushButton(tr( "Quit"), this) QPushButton *saveScreenshotButton = new QPushButton(tr( "Save Screenshot"), this) Ĭonnect(saveScreenshotButton, & QPushButton ::clicked, this, &Screenshot ::saveScreenshot) īuttonsLayout - >addWidget(saveScreenshotButton) NewScreenshotButton = new QPushButton(tr( "New Screenshot"), this) Ĭonnect(newScreenshotButton, & QPushButton ::clicked, this, &Screenshot ::newScreenshot) īuttonsLayout - >addWidget(newScreenshotButton) QHBoxLayout *buttonsLayout = new QHBoxLayout MainLayout - >addWidget(optionsGroupBox) OptionsGroupBoxLayout - >addWidget(hideThisWindowCheckBox, 1, 0, 1, 2) OptionsGroupBoxLayout - >addWidget(delaySpinBox, 0, 1) OptionsGroupBoxLayout - >addWidget( new QLabel(tr( "Screenshot Delay:"), this), 0, 0) QGridLayout *optionsGroupBoxLayout = new QGridLayout(optionsGroupBox) HideThisWindowCheckBox = new QCheckBox(tr( "Hide This Window"), optionsGroupBox) QGroupBox *optionsGroupBox = new QGroupBox(tr( "Options"), this) ĭelaySpinBox = new QSpinBox(optionsGroupBox) Ĭonnect(delaySpinBox, QOverload ::of( & QSpinBox ::valueChanged), this, &Screenshot ::updateCheckBox) MainLayout - >addWidget(screenshotLabel) QVBoxLayout *mainLayout = new QVBoxLayout( this) ScreenshotLabel - >setMinimumSize(screenGeometry. ScreenshotLabel - >setAlignment( Qt ::AlignCenter) Ĭonst QRect screenGeometry = screen() - >geometry() ScreenshotLabel - >setSizePolicy( QSizePolicy ::Expanding, QSizePolicy ::Expanding) The reason is that when we display the preview of the screenshot, we need to scale its pixmap, storing the original we make sure that no data are lost in that process. In addition we need to store the screenshot's original pixmap. ![]() We also declare the private function updateScreenshotLabel() which is called whenever a new screenshot is taken or when a resize event changes the size of the screenshot preview label.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |