⁸I started making a qt6 widget application. How do I get it to start in the upper right corner of the screen when I run the application.I've been struggling for hours but couldn't find the appropriate code to do this with cmake.Is there a way to install the cmake QDesktopWidget library ? I hoped that the code in the bold text would start in the upper right corner, but it was not as I expected, I can't find the problem.
#include "widget.h"
#include "./ui_widget.h"
#include <QScreen>
#include <QRect>
#include <QSize>
#include <QApplication>
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
{
ui->setupUi(this);
this->setWindowFlags(Qt::WindowType::FramelessWindowHint);
this->setAttribute(Qt::WA_TranslucentBackground);
this->setStyleSheet(".QFrame{background-color: red; border: 1px solid black; border-radius: 10px;}");
QRect sc = QGuiApplication::primaryScreen()->geometry();
QWidget::move(sc.top( ),sc.right());
Widget::show();
}
Widget::~Widget()
{
delete ui;
Try this:
this->move(QApplication::primaryScreen()->geometry().right()- this->rect().right(),
QApplication::primaryScreen()->geometry().top()- this->rect().top());