Category : qt

Whenever I press the Cancel button in the QFileDialog, the entire application closes, even the parent window. I want it so that only the file dialog closes and the parent window remains window. Here’s the application constructor along with the event listener (onSave()) that will show the QFileDialog when called. Whenever I click cancel, the ..

Read more

Case: App starts, MainWindow opens, then auto-show dialog window (call this A). There’s a button in A called ‘btn’. In MainWindow, I have a label called ‘sometext_label’. What I want is, when ‘btn’ is clicked, change ‘sometext_label’ text to "Hi!" for example, and then close dialog A. When dialog A is closed, the label’s text ..

Read more

I fight with printing pdf from QTextDocument object with html format. I generate QString formatted code of html page and it works fine. To test it i make using QFile a html file which have to be printed and it look greats. But pdf file looks completly different and i don’t know why. Code: QString ..

Read more

I am trying to initialize a shared_ptr to a QTextCodec (Qt class for charset conversion) in my class constructor. This is the code I have where I get a ‘virtual QTextCodec::~QTextCodec()’ is protected within this context error: myencoder.h #ifndef MYENCODER_H #define MYENCODER_H #include <memory> #include <QTextCodec> class MyEncoder { std::shared_ptr<QTextCodec> m_codec; public: MyEncoder(QString &aCodec); }; ..

Read more

I am uploading QPixmap to QTableView via QSqlTableModel. On Linux, images are displayed in normal quality, but on Windows, the image quality is very low. Is it possible to fix it somehow? Qt 6 fragment of my code: SqlTableModel::SqlTableModel(QObject *parent, QSqlDatabase db) : QSqlTableModel(parent, db) { int iconheight = QFontMetrics(QApplication::font()).height() * 2 – 4; m_IconSize ..

Read more

I need a scalable scroll bar, like in a audio or MIDI editor, can scale and scroll contents, handle’s width is adjustable to scale contents. Is it possible to get a scalable scroll bar in Qt 6? If not, is there any libraries or some readable code to handle it beautifully (not fancy)? Source: Windows ..

Read more

I have the following code: class Boundaries: public QObject{ Q_OBJECT enum Type{ in, out }; QDateTime m_startTimeBoundary{}; QDateTime m_endTimeBoundary{}; QDateTime m_from{}; QDateTime m_to{}; Q_PROPERTY(QDateTime fromDate READ getFromDate NOTIFY emitSignal1) Q_PROPERTY(QDateTime toDate READ getToDate NOTIFY emitSignal1) QDateTime getFromDate(){ return m_from; } QDateTime getToDate(){ return m_to; } public: signals: void emitSignal1(); public: void initBoundaries(const QDateTime& start,const QDateTime& ..

Read more