Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.6k Posts
  • Qt 6.5.3 : Can't change QWidget position

    Solved qwidget position geometry
    6
    0 Votes
    6 Posts
    1k Views
    P
    @JonB @JoeCFD OK found that Wayland just doesn't allow to windows to move themselves. Not a necessary feature for me and can't solve the black screen problem when logging with Xorg. Will just ask gnome to center new windows with tweaks. Closing the topic. Thanks to both you.
  • LTS Query

    Unsolved
    2
    0 Votes
    2 Posts
    151 Views
    Christian EhrlicherC
    Qt 6.3 is no LTS release, 6.2 and 6.5 are. But you can profit only when you have a commercial license.
  • Opengl undefined references with qchartview

    Unsolved
    2
    0 Votes
    2 Posts
    315 Views
    Christian EhrlicherC
    You need to link against the opengl library. see e.g. here: https://forum.qt.io/topic/84385/opengl32-lib-no-such-file-or-directory
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    3 Views
    No one has replied
  • How to connect signal by drug on Qt Creator signal slot editor mode?

    Solved
    3
    0 Votes
    3 Posts
    371 Views
    B
    @StudentScripter Thank you for your reply. Probably, but the problem is solved. For some reason in my environment, selecting buddy editting mode launches signal/slot editting mode. https://x.com/bigbenbigben/status/1707383342621229086?s=20
  • QGraphicsView and Qt::WA_AcceptTouchEvents

    Unsolved
    16
    0 Votes
    16 Posts
    1k Views
    M
    Thanks, this helped me to understand better what actually goes wrong. I changed the code of MyView as follows: class MyView : public QGraphicsView { public: MyView(QWidget *parent = nullptr) : QGraphicsView{parent} { setScene(new QGraphicsScene); viewport()->setAttribute(Qt::WA_AcceptTouchEvents); } bool viewportEvent(QEvent *event) override { qDebug() << "MyView::viewportEvent(QEvent *event)"; switch (event->type()) { case QEvent::TouchBegin: case QEvent::TouchUpdate: case QEvent::TouchEnd: qDebug() << "Some touch event"; return true; default: return QGraphicsView::viewportEvent(event); } } }; So now I can distinguish between getting any viewportEvent at all and getting touch events in particular (here I no longer distinguish between 1 or 2 finger events) Now I did the what you described: @Asperamanca said in QGraphicsView and Qt::WA_AcceptTouchEvents: I can drag the item out of the window, and receive touch events until I release I can enlarge the window and see the item again I can start another drag operation on the item, and the viewport event recognizes it, and the item is dragged First I get messages like MyView::viewportEvent(QEvent *event) Some touch event MyView::viewportEvent(QEvent *event) Some touch event ... when I move the item around. Once the item was dropped outside the viewport I just get MyView::viewportEvent(QEvent *event) MyView::viewportEvent(QEvent *event) ... So I actually still get viewport events. Except for touch events. It seems that touch events are now filtered out or no longer sent. Moving the item around was never the problem. The problem is that I use touch events gestures for zooming.
  • QMenu use menuaction

    Unsolved
    9
    0 Votes
    9 Posts
    832 Views
    C
    Are you trying to make a QTabWidget? It sounds (and looks) like you're trying to use the menubar as a tab bar.
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    7 Views
    No one has replied
  • Qt plugin for geodesics computing

    Unsolved
    3
    0 Votes
    3 Posts
    224 Views
    S
    @SGaist Well, what do you mean when you say something "like" the QtPositioning module ? And, what does it do, anyways ? I'll check it out. I'll checkout QGIS as well.
  • 0 Votes
    1 Posts
    319 Views
    No one has replied
  • QProcess with DPI issues.

    Unsolved
    2
    0 Votes
    2 Posts
    169 Views
    faduF
    @ZeusFa Hi Can you share screenshot explaining that
  • Printing image in Thermal printer

    Solved
    8
    0 Votes
    8 Posts
    2k Views
    Ramkumar MohanR
    @SGaist MainWindow.CPP #include "mainwindow.h" #include "ui_mainwindow.h" #include <QImage> #include <iostream> #include "printer.h" #include <QDebug> #include <unistd.h> #include <QPainter> #include <QBuffer> #include <QPainter> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); } MainWindow::~MainWindow() { delete ui; } QImage MainWindow::loadImage(const QString &filePath) { QImage image(filePath); if (image.isNull()) { qDebug() << "Error loading image: " << filePath; } return image; } void MainWindow::on_pushButton_clicked() { QApplication::processEvents(); Printer *printer = new Printer(); std::cout << "Trying to open port..." << std::endl; bool res = printer->open("/dev/ttyS0"); std::cout << "Status: " << res << std::endl; if (!res) { std::cerr << "Error opening port, aborting" << std::endl; return; } QString imagePath = "/home/pi/git/Image_Print/Raspberry_Pi.jpg"; // Replace with the path to your image QImage image = loadImage(imagePath); if (!image.isNull()) { qDebug()<<"Image enter"; printer->write("Data"); printer->feed(); printer->feed(); printer->printImage(image); printer->feed(); printer->feed(); } else { qDebug() << "Image is null or invalid."; } printer->close(); } Printer.CPP /***************************************************************** * Thermal Printer Interface Library based on QT for the Rasp-Pi * Based on the Arduino Library from Adafruit * using QExtSerialPort * Autor: Tobias Floery * E-Mail: tobias@floery.net ***************************************************************/ #include "printer.h" #include <QImage> #include <iostream> #include <unistd.h> #include <QDebug> #include <QPixmap> Printer::Printer(QObject *parent) : QObject(parent) { } // opens the serial port specified py path bool Printer::open(QString path) { port = new QextSerialPort(path); if (!port->open(QIODevice::WriteOnly)) return false; // set options port->setBaudRate(BAUD9600); port->setDataBits(DATA_8); port->setFlowControl(FLOW_OFF); port->setParity(PAR_NONE); usleep(10000); return true; } // close the serial port void Printer::close() { port->close(); } // write single byte void Printer::write(quint8 byte) { port->write((const char*)&byte, 1); } // write a string void Printer::write(QString str) { port->write(str.toUtf8()); } void Printer::writes(char SOMETHING) { port->write(&SOMETHING); } // initialize the printer void Printer::init() { reset(); setStatus(true); setControlParameter(); setPrintDensity(); setSleepTime(); setCodeTable(); setCharacterSet(); setBarcodePrintReadable(); } // reset the printer void Printer::reset() { write(27); write(64); usleep(50000); } // sets the printer online (true) or ofline (false) void Printer::setStatus(bool state) { write(27); write(61); write(state); } // set control parameters: heatingDots, heatingTime, heatingInterval void Printer::setControlParameter(quint8 heatingDots, quint8 heatingTime, quint8 heatingInterval) { write(27); write(55); write(heatingDots); write(heatingTime); write(heatingInterval); } // set sleep Time in seconds, time after last print the printer should stay awake void Printer::setSleepTime(quint8 seconds) { write(27); write(56); write(seconds); usleep(50000); write(0xFF); } // set double width mode: on=true, off=false void Printer::setDoubleWidth(bool state) { write(27); write(state?14:20); } // set the print density and break time void Printer::setPrintDensity(quint8 printDensity, quint8 printBreakTime) { write(18); write(35); write((printBreakTime << 5) | printDensity); } // set the used character set void Printer::setCharacterSet(CharacterSet set) { write(27); write(82); write(set); } // set the used code table void Printer::setCodeTable(CodeTable table) { write(27); write(116); write(table); } // feed single line void Printer::feed(void) { write(10); } // feed <<lines>> lines void Printer::feed(quint8 lines) { write(27); write(74); write(lines); } // set line spacing void Printer::setLineSpacing(quint8 spacing) { write(27); write(51); write(spacing); } // set Align Mode: LEFT, MIDDLE, RIGHT void Printer::setAlign(AlignMode align) { write(27); write(97); write(align); } // set how many blanks should be kept on the left side void Printer::setLeftBlankCharNums(quint8 space) { if (space >= 47) space = 47; write(27); write(66); write(space); } // set Bold Mode: on=true, off=false void Printer::setBold(bool state) { write(27); write(32); write((quint8) state); write(27); write(69); write((quint8) state); } // set Reverse printing Mode void Printer::setReverse(bool state) { write(29); write(66); write((quint8) state); } // set Up/Down Mode void Printer::setUpDown(bool state) { write(27); write(123); write((quint8) state); } // set Underline printing void Printer::setUnderline(bool state) { write(27); write(45); write((quint8) state); } // enable / disable the key on the frontpanel void Printer::setKeyPanel(bool state) { write(27); write(99); write(53); write((quint8) state); } // where should a readable barcode code be printed void Printer::setBarcodePrintReadable(PrintReadable n) { write(29); write(72); write(n); } // sets the height of the barcode in pixels void Printer::setBarcodeHeight(quint8 height) { if (height <= 1) height = 1; write(29); write(104); write(height); } // sets the barcode line widths (only 2 or 3) void Printer::setBarCodeWidth(quint8 width) { if (width <= 2) width=2; else if (width >= 3) width=3; write(29); write(119); write(width); } // prints a barcode void Printer::printBarcode(QString data, BarcodeType type) { write(29); write(107); write(type); write(data); write(0); } bool Printer::isPrinterReady() { return port->isOpen() && port->isWritable(); } void Printer::printImage(const QImage &image) { if (!isPrinterReady()) { qDebug() << "Printer is not ready."; return; } qreal scaleFactor = 2.0; // Increase DPI by a factor of 2 qreal darknessFactor =1.0; // Adjust darkness level (experiment with this value) // Scale the image for higher DPI (dots per inch) QImage highDpiImage = image; // Disable device pixel ratio scaling (anti-aliasing) highDpiImage.setDevicePixelRatio(1); QImage monochromeImage = highDpiImage.convertToFormat(QImage::Format_Mono); highDpiImage = monochromeImage.scaled(monochromeImage.width() * scaleFactor, monochromeImage.height() * scaleFactor, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); // Calculate the width of the image in bytes int bytesPerLine = (monochromeImage.width() + 7) / 8; // Send the ESC/POS command to print the image QByteArray printCommand; printCommand.append(char(0x1D)); // ESC printCommand.append(char(0x76)); // 'v' printCommand.append(char(0x30)); // '0' printCommand.append(char(0x00)); // Mode (0 for normal) // Append the image width and height printCommand.append(char(bytesPerLine & 0xFF)); printCommand.append(char((bytesPerLine >> 8) & 0xFF)); printCommand.append(char(monochromeImage.height() & 0xFF)); printCommand.append(char((monochromeImage.height() >> 8) & 0xFF)); // Send the print command port->write(printCommand); // Send the image data QByteArray imageData; for (int y = 0; y < monochromeImage.height(); ++y) { for (int x = 0; x < bytesPerLine; ++x) { uchar byte = 0; for (int bit = 0; bit < 8; ++bit) { int pixelX = x * 8 + bit; if (pixelX < monochromeImage.width()) { bool isBlackPixel = monochromeImage.pixel(pixelX, y) == qRgb(0, 0, 0); byte |= (isBlackPixel ? 0x01 : 0x00) << (7 - bit); // Corrected bit order } } byte *= darknessFactor; // Adjust this factor for darkness level imageData.append(byte); } } // Send the image data port->write(imageData); write("\n"); // Print a newline to advance to the next line } I solved my issue with the above code. Thanks .... OUTPUT.. [image: 20bfee1d-563c-4bff-9884-1d1382f6287a.jpeg] Original Image [image: 47d60aeb-3191-4cc2-a279-6d89a428cf45.jpg]
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    3 Views
    No one has replied
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    3 Views
    No one has replied
  • Qt Online Installer issues

    Unsolved
    2
    0 Votes
    2 Posts
    178 Views
    sierdzioS
    @JacobNovitsky You might have hit the time when servers were updating after release of Qt 6.2.6. Please try again
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    3 Views
    No one has replied
  • ScrollView with TextArea material style exceeds height

    Unsolved qml material design
    1
    0 Votes
    1 Posts
    192 Views
    No one has replied
  • Test QT widget application from a Separated Auto test Project

    Unsolved
    2
    0 Votes
    2 Posts
    131 Views
    SGaistS
    Hi and welcome to devnet, Do you mean something like described in the Qt Test module documentation ?
  • Photoshop layer like QTreeWidget Qt6 C++ - Help needed.

    Unsolved c++ qt6 qtreewidget qtreeview delegate
    5
    0 Votes
    5 Posts
    922 Views
    SGaistS
    @StudentScripter For the grouping you have to use an adequate data structure. As for hovering, IIRC, you have to have mouse tracking enabled on the view.
  • Applying a style to a QTableView object

    Unsolved
    2
    0 Votes
    2 Posts
    211 Views
    SGaistS
    Hi, If you want to do styled painting you should rather use the QStyledItemDelegate as a base. Next, how do you expect the default QStyle to make use of your custom options ? It knows nothing about them. Depending on what you want to achieve you should write a proxy style that make use of your custom options.