Programming/qt2026. 4. 28. 10:28

필요한게 uitools, multimedia, linguist 라서 좀 고생

 

sudo apt install -y qtcreator qtbase5-dev qt5-qmake cmake qttools5-dev-tools qttools5-dev qtmultimedia5-dev

 

어우 속이 다 편안하네. qt6 가 문제인건가..

어짜피 target에서 qt6 쓸수 있는 상황아니면 굳이 qt6을 고집할 필요는 없지 머.

 

와.. 그 개고생했던게 한방에 해결이네

 

[링크 : https://askubuntu.com/questions/1404263/how-do-you-install-qt-on-ubuntu22-04]

[링크 : https://stackoverflow.com/questions/20670457/qt-5-unknown-modules-in-qt-uitools]

[링크 : https://stackoverflow.com/questions/70720437/how-to-install-qmultimedia-on-ubuntu]

'Programming > qt' 카테고리의 다른 글

qt5 gif 애니메이션  (0) 2026.04.28
qt5 다국어 지원 테스트  (0) 2026.04.28
Qimage 단색 비트맵  (0) 2026.04.27
qt 위젯 캡쳐  (0) 2026.04.27
qt layout  (0) 2026.04.22
Posted by 구차니
Programming/qt2026. 4. 27. 15:19

 

 

QImage QImage::convertToFormat(QImage::Format format, Qt::ImageConversionFlags flags = Qt::AutoColor) const &
QImage QImage::convertToFormat(QImage::Format format, Qt::ImageConversionFlags flags = Qt::AutoColor) &&
QImage QImage::convertedTo(QImage::Format format, Qt::ImageConversionFlags flags = Qt::AutoColor) const &

[링크 : https://doc.qt.io/qt-6/qimage.html#convertToFormat]

 

'(기본값)'으로 표시된 옵션은 목록의 다른 값이 포함되지 않은 경우 설정됩니다(기본값은 0이므로):

색상/모노 기본 설정 ( QBitmap)의 경우 무시됩니다:

상수 값 설명
Qt::AutoColor 0x00000000 (기본값) - 이미지에 depth 1이 있고 흑백 픽셀만 포함된 경우, 픽셀맵은 흑백이 됩니다.
Qt::ColorOnly 0x00000003 픽셀맵이 디더링/변환되어 native display depth.
Qt::MonoOnly 0x00000002 픽셀맵이 흑백이 됩니다. 필요한 경우 선택한 디더링 알고리즘을 사용하여 디더링됩니다.

[링크 : https://doc.qt.io/qt-6/ko/qt.html#ImageConversionFlag-enum]

 

Constant Value Description
QImage::Format_Invalid 0 The image is invalid.
QImage::Format_Mono 1 The image is stored using 1-bit per pixel. Bytes are packed with the most significant bit (MSB) first.

[링크 : https://doc.qt.io/qt-6/qimage.html#Format-enum]

'Programming > qt' 카테고리의 다른 글

qt5 다국어 지원 테스트  (0) 2026.04.28
qt5 설치하기 on ubunut 22.04  (0) 2026.04.28
qt 위젯 캡쳐  (0) 2026.04.27
qt layout  (0) 2026.04.22
qt 다국어지원 관련  (0) 2026.04.22
Posted by 구차니
Programming/qt2026. 4. 27. 14:46

 

[링크 : https://1d1cblog.tistory.com/333]

 

qt4.4

QPixmap QPixmap::grabWindow ( WId window, int x = 0, int y = 0, int width = -1, int height = -1 ) 
QPixmap QPixmap::grabWidget ( QWidget * widget, int x = 0, int y = 0, int width = -1, int height = -1 )  

[링크 : https://radekp.github.io/qtmoko/api/qpixmap.html#grabWindow]

[링크 : https://radekp.github.io/qtmoko/api/qpixmap.html#grabWidget-2]

 

qt 5

QPixmap QWidget::grab(const QRect &rectangle = QRect(QPoint(0, 0), QSize(-1, -1)))

[링크 : https://doc.qt.io/qt-6/qwidget.html#grab]

 

qt 6?

QPixmap QScreen::grabWindow(WId window = 0, int x = 0, int y = 0, int width = -1, int height = -1)

[링크 : https://doc.qt.io/qt-6/qscreen.html#grabWindow]

 

 

chatgpt 가라사대. 

pixmap 으로 grab 해서 만들고

그걸 QBuffer를 이용해서 저장을 내보내면 파일로 안만들어도 된다고 한다.

QPixmap pixmap = widget->grab();  // 또는 grabWindow 등

QByteArray byteArray;
QBuffer buffer(&byteArray);
buffer.open(QIODevice::WriteOnly);

// BMP 포맷으로 메모리에 저장
pixmap.save(&buffer, "BMP");

// 이제 byteArray 안에 BMP 바이너리 데이터가 들어 있음

'Programming > qt' 카테고리의 다른 글

qt5 설치하기 on ubunut 22.04  (0) 2026.04.28
Qimage 단색 비트맵  (0) 2026.04.27
qt layout  (0) 2026.04.22
qt 다국어지원 관련  (0) 2026.04.22
qt ui loader  (0) 2026.04.01
Posted by 구차니
Programming/qt2026. 4. 22. 18:18

해상도에 자동으로 늘어나는거 해보고 싶다!

[링크 : https://eskeptor.tistory.com/39]

 

+

2026.04.28

 

 

 

lay out in a grid 했더니 창 크기에 따라서 알아서 커지는데

ui 파일 열어보니 sizeconstrint가 추가되어서 되는 듯?

  <widget class="QWidget" name="centralwidget">
   <layout class="QGridLayout" name="gridLayout_2">
    <item row="0" column="0">
     <layout class="QGridLayout" name="gridLayout">
      <property name="sizeConstraint">
       <enum>QLayout::SetMaximumSize</enum>
      </property>

 

layout 위젯의 경우 Window창이 늘어남에 따라 자동으로 크기가 조절되게 해야할 경우. 위젯이 아닌 배경에서 우클릭후 Lay Out 컨텍스트 메뉴에서 레이아웃을 선택하면 크기가 레이아웃에 따라 자동으로 맞춰진다.

[링크 : https://wikidocs.net/3842]

 

 

+

[링크 : https://toytvstory.tistory.com/1421]

'Programming > qt' 카테고리의 다른 글

Qimage 단색 비트맵  (0) 2026.04.27
qt 위젯 캡쳐  (0) 2026.04.27
qt 다국어지원 관련  (0) 2026.04.22
qt ui loader  (0) 2026.04.01
qt widget fullscreen  (0) 2026.03.31
Posted by 구차니
Programming/qt2026. 4. 22. 14:31

lrelease 라는 별도 실행파일이 있어야 하는 것 같고

[링크 : https://doc.qt.io/qt-6/ko/linguist-lrelease.html]

[링크 : https://doc.qt.io/qt-6/ko/qtlinguist-index.html]

 

qttools를 받아야 하는것 처럼 보인다.

[링크 : https://fortex66.tistory.com/40]

[링크 : https://github.com/qt/qttools]

[링크 : https://doc.qt.io/tools.html]

 

qt6 깔고 유지보수 도구 내에서는 영.. 없네. 먼가 마음에 안들어 -_-

'Programming > qt' 카테고리의 다른 글

qt 위젯 캡쳐  (0) 2026.04.27
qt layout  (0) 2026.04.22
qt ui loader  (0) 2026.04.01
qt widget fullscreen  (0) 2026.03.31
qt media 재생하기  (0) 2026.03.31
Posted by 구차니

제목이 먼가 드럽게 긴데

네이버 블로그 같은데서

로컬 파일을 읽어서 사용자가 올리듯 이미지를 원하는 위치에 붙여 넣는 방법을 고민중

 

[링크 : https://wikidocs.net/236864] pyperclip - 클립보드 라이브러리

[링크 : https://github.com/asweigart/pyperclip]

[링크 : https://pypi.org/project/pyperclip/]

 

[링크 : https://wikidocs.net/85581] pyautogui - 마우스 자동화

[링크 : https://github.com/asweigart/pyautogui]

[링크 : https://pypi.org/project/PyAutoGUI/]

'Programming > python(파이썬)' 카테고리의 다른 글

python venv  (0) 2026.06.17
python switch-case -> match-case  (0) 2025.10.11
python __name__  (0) 2025.09.29
python flask를 이용한 static web + rest api server 구현  (0) 2025.09.29
python simsimd  (0) 2025.08.28
Posted by 구차니
Programming/node.js2026. 4. 9. 22:13

lynx는 리눅스 cli 용 텍스트 브라우저 인데

과거에(한 2000년대 초반)는 그래도 첫 페이지 접속하면 정직하게(!) html이 날아와서

인터넷이 느리거나 하면 lynx로 테스트만 보곤 했는데

 

요즘에는 javascript 지원 브라우저를 통해

javascript를 처리해서 다른 url로 넘어가야 페이지가 보이게 되어있다 보니 lynx로 접속하면 이런 화면만 보게 된다.

 

                                                                                                                                                Google
   브라우저 업데이트
   이 브라우저는 더 이상 지원되지 않습니다. 계속 검색하려면 최신 버전으로 업그레이드하세요. 자세히 알아보기

 

#                                                                                                                                                 Daum
   #다음

   이 사이트의 기능을 모두 활용하기 위해서는 자바스크립트를 활성화 시킬 필요가 있습니다. 브라우저에서 자바스크립트를 활성화하는 방법을 참고 하세요.

[링크 : https://lynx.invisible-island.net/]

 

아무튼 이걸 우회하기 위해서는 자바스크립트를 지원하는 녀석이 필요한데

그때 만만(?)한게 셀레니움(selenium).

셀레니움을 통해서 접속하면 모니터 다리지 않은 가상의 브라우저에서 접속해서

자바스크립트 까지 처리된 페이지를 얻을수 있다.

 

요건 gpt 에서 생성해준 초기 기능 테스트용 코드

접속하고 body 태그 하위의 내용들을 getText()를 이용해 얻어와서 보여준다.

const { Builder, By } = require('selenium-webdriver');
const chrome = require('selenium-webdriver/chrome');
const readline = require('readline');

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

async function startBrowser(startUrl) {
    const options = new chrome.Options();
    options.addArguments('--headless=new');
    options.addArguments('--no-sandbox');
    options.addArguments('--disable-gpu');

    const driver = await new Builder()
        .forBrowser('chrome')
        .setChromeOptions(options)
        .build();

    let currentUrl = startUrl;

    while (true) {
        try {
            await driver.get(currentUrl);

            console.clear();

            /* ===== 본문 텍스트 출력 ===== */
            const bodyText = await driver
                .findElement(By.tagName('body'))
                .getText();

            console.log(bodyText.substring(0, 3000));
            console.log('\n---------------- LINKS ----------------');

            /* ===== 링크 수집 ===== */
            const elements = await driver.findElements(By.css('a'));
            const links = [];

            for (let i = 0; i < elements.length; i++) {
                const text = await elements[i].getText();
                const href = await elements[i].getAttribute('href');

                if (href && text.trim()) {
                    links.push({ index: links.length, text, href });
                }
            }

            links.forEach(l => {
                console.log(`[${l.index}] ${l.text}`);
            });

            console.log('\n[q] 종료');

            /* ===== 사용자 입력 ===== */
            const answer = await new Promise(resolve =>
                rl.question('\n이동할 링크 번호: ', resolve)
            );

            if (answer === 'q') break;

            const idx = parseInt(answer);
            if (!isNaN(idx) && links[idx]) {
                currentUrl = links[idx].href;
            }

        } catch (err) {
            console.error('오류 발생:', err.message);
            break;
        }
    }

    await driver.quit();
    rl.close();
}

/* 시작 URL */
startBrowser('https://example.com');

 

 

그리고 페이지 업/다운으로 페이지 이동하고

화살표로는 링크들 이동, 엔터는 해당 링크 따라가기 로 해서 구현한게 아래 코드

const blessed = require('blessed');
const { Builder } = require('selenium-webdriver');
const chrome = require('selenium-webdriver/chrome');

const startUrl = process.argv[2] || 'https://example.com';

let driver;
let history = [];

let lines = [];
let linkIndexes = [];
let selectedLink = 0;
let scroll = 0;

let title = '';
let currentUrl = '';

/* ================= Selenium ================= */

async function loadPage(url, pushHistory = true) {
  if (pushHistory && currentUrl) history.push(currentUrl);

  await driver.get(url);
  currentUrl = url;
  title = await driver.getTitle();

  const pageData = await driver.executeScript(() => {
    const result = [];

    function walk(node) {
      if (node.nodeType === Node.TEXT_NODE) {
        const t = node.textContent.replace(/\s+/g, ' ').trim();
        if (t) result.push({ text: t });
        return;
      }

      if (node.nodeType !== Node.ELEMENT_NODE) return;

      const tag = node.tagName.toLowerCase();

      if (tag === 'a' && node.href && node.innerText.trim()) {
        result.push({ text: node.innerText.trim(), href: node.href });
        return;
      }

      if (['script','style','noscript'].includes(tag)) return;

      if (['p','div','section','article','li','pre','blockquote',
           'h1','h2','h3','h4','h5','h6'].includes(tag)) {
        node.childNodes.forEach(walk);
        result.push({ text: '' });
        return;
      }

      node.childNodes.forEach(walk);
    }

    walk(document.body);
    return result;
  });

  lines = [];
  linkIndexes = [];

  pageData.forEach(item => {
    const idx = lines.length;
    if (item.href) {
      lines.push({ text: item.text, href: item.href, selectable: true });
      linkIndexes.push(idx);
    } else {
      lines.push({ text: item.text, selectable: false });
    }
  });

  scroll = 0;
  selectedLink = 0;
}

/* ================= Selection / Scroll ================= */

function recalcSelectionInView() {
  const top = scroll;
  const bottom = scroll + body.height - 1;

  const visible = linkIndexes.filter(i => i >= top && i <= bottom);
  if (visible.length)
    selectedLink = linkIndexes.indexOf(visible[0]);
}

function drawScrollbar() {
  const total = lines.length;
  const view = body.height;
  if (total <= view) return;

  const maxScroll = total - view;
  const barHeight = Math.max(1, Math.floor(view * view / total));
  const barTop = Math.floor(scroll * (view - barHeight) / maxScroll);

  for (let i = 0; i < barHeight; i++) {
    const line = body.getLine(barTop + i);
    if (line !== undefined) {
      body.setLine(barTop + i, line + '▐');
    }
  }
}

/* ================= TUI ================= */

const screen = blessed.screen({
  smartCSR: true,
  fullUnicode: true,
  title: 'Text Browser'
});

const header = blessed.box({ top: 0, height: 2, tags: true });

const body = blessed.box({
  top: 2,
  bottom: 2,
  tags: true
});

/* footer를 두 줄로 분리 */
const footerHelp = blessed.box({
  bottom: 1,
  height: 1,
  tags: true
});

const footerSelected = blessed.box({
  bottom: 0,
  height: 1,
  tags: true
});

screen.append(header);
screen.append(body);
screen.append(footerHelp);
screen.append(footerSelected);

function render() {
  const height = body.height;
  const visible = lines.slice(scroll, scroll + height);
  const selectedLine = linkIndexes[selectedLink];

  header.setContent(`{bold}${title}{/bold}\n${currentUrl}`);

  body.setContent(
    visible.map((l, i) => {
      const idx = scroll + i;
      if (l.selectable) {
        if (idx === selectedLine)
          return `{white-fg}{blue-bg}${l.text}{/}`;
        return `{blue-fg}{underline}${l.text}{/}`;
      }
      return l.text;
    }).join('\n')
  );

  drawScrollbar();

  footerHelp.setContent(
    `{dim}↑↓ 이동  PgUp/PgDn 페이지  Enter 열기  b 뒤로  q 종료{/dim}`
  );

  footerSelected.setContent(
    `{bold}Selected:{/bold} ${lines[selectedLine]?.href || ''}`
  );

  screen.render();
}

/* ================= Keys ================= */

function moveSelection(delta) {
  const next = selectedLink + delta;
  if (next < 0 || next >= linkIndexes.length) return;

  selectedLink = next;
  const idx = linkIndexes[selectedLink];

  if (idx < scroll) scroll = idx;
  if (idx >= scroll + body.height)
    scroll = idx - body.height + 1;

  render();
}

screen.key('up', () => moveSelection(-1));
screen.key('down', () => moveSelection(1));

screen.key('pageup', () => {
  scroll = Math.max(0, scroll - body.height);
  recalcSelectionInView();
  render();
});

screen.key('pagedown', () => {
  scroll = Math.min(
    Math.max(0, lines.length - body.height),
    scroll + body.height
  );
  recalcSelectionInView();
  render();
});

screen.key('enter', async () => {
  const line = lines[linkIndexes[selectedLink]];
  if (line?.href) {
    await loadPage(line.href);
    render();
  }
});

screen.key('b', async () => {
  if (history.length) {
    await loadPage(history.pop(), false);
    render();
  }
});

screen.key('resize', () => {
  recalcSelectionInView();
  render();
});

screen.key(['q','C-c'], async () => {
  if (driver) await driver.quit();
  process.exit(0);
});

/* ================= Init ================= */

(async () => {
  const options = new chrome.Options();
  options.addArguments('--headless=new');

  driver = await new Builder()
    .forBrowser('chrome')
    .setChromeOptions(options)
    .build();

  await loadPage(startUrl);
  render();
})();

[링크 : https://chatgpt.com/share/697b1d46-a670-800c-a520-0d6289a4391c]

'Programming > node.js' 카테고리의 다른 글

electron asar 파일  (0) 2025.08.26
node excel export  (0) 2024.07.18
web qr decoder  (0) 2024.04.04
node.js 웹소켓 채팅 서버 예제  (0) 2022.07.14
ubuntu 18.04 / nodej.s 18.x 실패  (0) 2022.05.19
Posted by 구차니
Programming/qt2026. 4. 1. 14:56

QT 에서 ui를 사용하는? 불러오는? 방법은 크게 두가지가 있는데

하나는 ui 파일을 "런타임"에 읽어와서 사용하는 것이고

다른 하나는 qic 를 통해 cpp/h 로 변환해서 사용하는 것이다.

[링크 : https://doc.qt.io/qt-6/ko/designer-using-a-ui-file.html]

 

QT Ui Loader 를 이용하여 런타임중에 불러와서 쓰는 것과 

Header: #include <QUiLoader>
CMake: find_package(Qt6 REQUIRED COMPONENTS UiTools)
target_link_libraries(mytarget PRIVATE Qt6::UiTools)
qmake: QT += uitools

[링크 : https://doc.qt.io/qt-6/quiloader.html]

 

 

qt designer로 디자인하고

[링크 : https://doc.qt.io/qt-6/ko/qtdesigner-manual.html]

 

qic를 통해 소스로 변환하는 것이 있다.

[링크 : https://doc.qt.io/qt-6/ko/uic.html]

 

어쩌면 python을 위해 동적 로드가 추가된거 아닐까 생각도?

[링크 : https://doc.qt.io/qt-6/ko/designer-using-a-ui-file-python.html]

 

프로젝트 파일에 widgets가 들어가면 자동으로 변경되는것 처럼 이야기 하는데

6.x 면 기본으로 들어가게 되어있지만 그렇다고 자동으로 ui 파일 기반으로 변경하진 않는다.

QT       += core gui multimedia uitools

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

[링크 : https://www.qtcentre.org/threads/36215-qmake-not-invoking-uic]

[링크 : https://doc.qt.io/archives/qt-5.15/qtwidgets-index.html]

[링크 : https://stackoverflow.com/questions/38549747/qmake-doesnt-invoke-uic]

 

QMAKE_UIC_FLAGS += -a

[링크 : https://doc.qt.io/archives/qt-5.15/qmake-variable-reference.html#qmake-uic-flags]

[링크 : https://forum.qt.io/topic/129602/how-to-pass-option-to-uic-in-qmake-project-file/2]

 

 

 

In specific cases, such as the example below where the include directive uses a relative path, qt_add_ui can be used to generate the ui_calculatorform.h file instead of relying on AUTOUIC.
When to prefer qt_add_ui over AUTOUIC

[링크 : https://doc.qt.io/qt-6/designer-using-a-ui-file.html]

[링크 : https://cmake.org/cmake/help/latest/manual/cmake-qt.7.html#autouic]

[링크 : https://doc.qt.io/qt-6/qt-add-ui.html]

 

include 지시어가 상대 경로를 사용하는 아래 예제와 같은 특정 경우에는 AUTOUIC에 의존하는 대신 qt_add_ui를 사용하여 ui_calculatorform.h 파일을 생성할 수 있습니다.
AUTOUIC보다 qt_add_ui를 선호하는 경우

[링크 : https://doc.qt.io/qt-6/ko/designer-using-a-ui-file.html]

[링크 : https://doc.qt.io/qt-6/uic.html]

 

 

'Programming > qt' 카테고리의 다른 글

qt layout  (0) 2026.04.22
qt 다국어지원 관련  (0) 2026.04.22
qt widget fullscreen  (0) 2026.03.31
qt media 재생하기  (0) 2026.03.31
qt concurrent / qt thread  (0) 2026.03.30
Posted by 구차니
Programming/qt2026. 3. 31. 16:13

qt designer 상에서 딸깍하면되는거 없나?

 

    MainWindow w;

    // w.setWindowState(w.windowState() ^ Qt::WindowFullScreen);
    // w.show();
    w.showFullScreen();

[링크 : https://doc.qt.io/qt-6/qwidget.html]

[링크 : https://m.blog.naver.com/lithium81/80143225704]

'Programming > qt' 카테고리의 다른 글

qt 다국어지원 관련  (0) 2026.04.22
qt ui loader  (0) 2026.04.01
qt media 재생하기  (0) 2026.03.31
qt concurrent / qt thread  (0) 2026.03.30
Qtimer를 이용한 반복/1회성 이벤트 생성  (0) 2026.03.30
Posted by 구차니
Programming/qt2026. 3. 31. 10:17

mainwindow.h

#include <QAudioOutput>
#include <QMediaPlayer>

class MainWindow : public QMainWindow
{
private:
    Ui::MainWindow *ui;
    QMediaPlayer *player;
    QAudioOutput *audioOutput;
};

 

mainwindow.cpp

QAudioOutput을 넣어주지 않으면 재생되는것 처럼 보이는데 정작 소리가 안나온다.

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    player = new QMediaPlayer;
    audioOutput = new QAudioOutput;
    player->setAudioOutput(audioOutput);

    player->setSource(QUrl::fromLocalFile("/home/minimonk/src/qt/sounds/test.mp3"));
    // player->setSource(QUrl("qrc:/test/sounds/test.mp3"));
    audioOutput->setVolume(0.5);

    player->play();
}

[링크 : https://doc.qt.io/qt-6/ko/audiooverview.html]

[링크 : https://doc.qt.io/qt-6/ko/qmediaplayer.html]

[링크 : https://doc.qt.io/qt-6/ko/qaudiooutput.html]

 

test.pro

곱게(?) ui 내에서 추가하는 법 없나?

QT       += core gui multimedia

[링크 : https://vongole-pasta.tistory.com/56]

 

아무튼 이렇게 하면 창이 열리면서 음악이 재생된다.

 

QMediaPlaylist *playlist = new QMediaPlaylist();
playlist->addMedia(QUrl("qrc:/sounds/backgroundmusic.mp3"));
playlist->setPlaybackMode(QMediaPlaylist::Loop);

QMediaPlayer *music = new QMediaPlayer();
music->setPlaylist(playlist);
music->play();

[링크 : https://stackoverflow.com/questions/37690616/play-background-music-in-a-loop-qt]

 

요건 시그널/슬롯 이용

[링크 : https://makeutil.tistory.com/117]

'Programming > qt' 카테고리의 다른 글

qt ui loader  (0) 2026.04.01
qt widget fullscreen  (0) 2026.03.31
qt concurrent / qt thread  (0) 2026.03.30
Qtimer를 이용한 반복/1회성 이벤트 생성  (0) 2026.03.30
qt5/6 시그널  (0) 2026.03.30
Posted by 구차니