Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.6k Posts
  • Do I need to include Q headers inner Q headers and to make these pre-compiled

    Locked Unsolved
    5
    0 Votes
    5 Posts
    344 Views
    Christian EhrlicherC
    Dupe of https://forum.qt.io/topic/150964/how-to-set-needed-permission-so-i-can-edit-qt-headers-from-qt-creator Please stop spamming the forum with the same question...
  • How to use precompiled headers (pch) for C++ with Qt

    Locked Unsolved
    9
    0 Votes
    9 Posts
    1k Views
    Christian EhrlicherC
    Dupe of https://forum.qt.io/topic/150964/how-to-set-needed-permission-so-i-can-edit-qt-headers-from-qt-creator/6
  • pre-compile Qt headers

    Locked Unsolved
    2
    0 Votes
    2 Posts
    149 Views
    Christian EhrlicherC
    Dupe of https://forum.qt.io/topic/150964/how-to-set-needed-permission-so-i-can-edit-qt-headers-from-qt-creator
  • How to set needed permission so I can edit qt headers from qt creator?

    Unsolved
    6
    0 Votes
    6 Posts
    541 Views
    C
    @JacobNovitsky Just follow the example in the documentation Project file. Only 2 lines added QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++17 # You can make your code fail to compile if it uses deprecated APIs. # In order to do so, uncomment the following line. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 CONFIG += precompile_header PRECOMPILED_HEADER = precompiled.h SOURCES += \ main.cpp \ widget.cpp HEADERS += \ widget.h # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target Headers to be precompiled (precompiled.h): // Add C includes here // none in this example #if defined __cplusplus // Add stable C++ includes here #include <QApplication> #include <QPushButton> #include <QLabel> #include <QLineEdit> #endif And the unmodified code of the program: #ifndef WIDGET_H #define WIDGET_H #include <QWidget> class Widget : public QWidget { Q_OBJECT public: Widget(QWidget *parent = nullptr); ~Widget(); }; #endif // WIDGET_H #include "widget.h" #include <QLabel> #include <QPushButton> #include <QLineEdit> #include <QVBoxLayout> Widget::Widget(QWidget *parent) : QWidget(parent) { QVBoxLayout *layout = new QVBoxLayout(this); QLabel *label = new QLabel("Hello, world!"); QPushButton *button = new QPushButton("Hello, button!"); QLineEdit *edit = new QLineEdit("Hello, editor!"); layout->addWidget(label); layout->addWidget(button); layout->addWidget(edit); } Widget::~Widget() { } #include "widget.h" #include <QApplication> int main(int argc, char *argv[]) { QApplication a(argc, argv); Widget w; w.show(); return a.exec(); } Re-run qmake, build, and precompiling/using the headers will happen. Any header not in the precompiled set will be handled normally.
  • Changing a QCalenderWidgets icons.

    Solved qcalenderwidget qprivatewidget
    8
    0 Votes
    8 Posts
    4k Views
    R
    this is what worked for me class CalendarWidget(QtWidgets.QCalendarWidget): def __init__(self, parent=None): super(CalendarWidget, self).__init__(parent, verticalHeaderFormat=QtWidgets.QCalendarWidget.NoVerticalHeader, gridVisible=False) self.setObjectName("patient_visit_date_calendar_widget") prev_button = self.findChild(QtWidgets.QToolButton, "qt_calendar_prevmonth") next_button = self.findChild(QtWidgets.QToolButton, "qt_calendar_nextmonth") # Create QIcon instances for your icons prev_icon = QIcon(":resources/icons/arrow_back.svg") next_icon = QIcon(":resources/icons/arrow_forward.svg") # Set the icons to the buttons prev_button.setIcon(prev_icon) next_button.setIcon(next_icon) for btn in (prev_button, next_button): btn.setIconSize(QtCore.QSize(15, 15)) for d in (QtCore.Qt.Saturday, QtCore.Qt.Sunday,): fmt = self.weekdayTextFormat(d) fmt.setForeground(QtCore.Qt.darkGray) self.setWeekdayTextFormat(d, fmt) self.setStyleSheet(QSS) def paintCell(self, painter, rect, date): if date == self.selectedDate(): painter.save() painter.fillRect(rect, QtGui.QColor("white")) painter.setPen(QtCore.Qt.NoPen) painter.setBrush(QtGui.QColor(10, 186, 181, 100)) r = QtCore.QRect(QtCore.QPoint(), min(rect.width(), rect.height())*QtCore.QSize(1, 1)) r.moveCenter(rect.center()) painter.drawEllipse(r) painter.setPen(QtGui.QPen(QtGui.QColor("white"))) painter.drawText(rect, QtCore.Qt.AlignCenter, str(date.day())) painter.restore() else: super(CalendarWidget, self).paintCell(painter, rect, date)
  • Qt Project freezes at start and does not show window

    Unsolved
    5
    0 Votes
    5 Posts
    561 Views
    SGaistS
    Did you already start your application with the QT_DEBUG_PLUGINS environment set to one ?
  • QMediaPlayer Problems with H265 and H264 Streams.

    Unsolved
    2
    0 Votes
    2 Posts
    2k Views
    SGaistS
    Hi and welcome to devnet, It seems you are missing the libva package on your system. Also, which version of OpenSSL do you have installed ?
  • 0 Votes
    4 Posts
    531 Views
    SGaistS
    Creating a base widget that does that handling is the correct way. However you can't optimize more. Each of your widgets will have custom texts and that's normal so streamlining where the code should be is already a good gain.
  • QHttpServer with mutual TLS authentication

    Unsolved
    2
    0 Votes
    2 Posts
    603 Views
    S
    @tomas-soltys "I think I need to get access to QSslSocket which can then further provide certificate details" Find QHttpServer source code. I mean QHttpServer.cpp and QHttpServer.h Modify the code so that you can get QSslSocket object. Then you can use: QSslCertificate QSslSocket::peerCertificate() const "Returns the peer's digital certificate (i.e., the immediate certificate of the host you are connected to), or a null certificate, if the peer has not assigned a certificate.". I have question to you: what version of Qt and openssl you use. Look at my post: maybe you can help me to get read of ssl connection issue . Link: https://forum.qt.io/topic/150462/qhttpserver-api-https-openssl-letsencrypt-sslv3-alert-handshake-failure-alert-number-40/6?_=1697291376846
  • QtMultimedia ffmpeg backend and Openssl library version mixup

    Unsolved
    7
    0 Votes
    7 Posts
    568 Views
    O
    @vladstelmahovsky said in QtMultimedia ffmpeg backend and Openssl library version mixup: @oniongarlic yes, I can confirm that ffmpeg backend cant playback rtsp streams. Not sure if its due to ssl library not found error My problem is with HLS streams, I get the first frame and then an error (ffplay works fine) (Windows, Mac) Linux won't even get that far with this ssl issue.
  • Model/View and Custom Data Models - Data in the backend

    Unsolved modelview custom model qabstractmodel
    4
    0 Votes
    4 Posts
    747 Views
    Christian EhrlicherC
    You can add custom functions to e.g. bulk-add data to the model but must not forget the call the appropriate changed signals. This is a common way of adding data since it's to slow through setData() when a lot of stuff is changing.
  • QUuid change variant

    Unsolved
    2
    0 Votes
    2 Posts
    210 Views
    C
    @MadBee I think you are confusing the UUID variant (DCE, the variant described in RFC 4122) with the UUID version (a sub-type of variant): The following table lists the currently-defined versions for this UUID variant. Msb0 Msb1 Msb2 Msb3 Version Description 0 0 0 1 1 The time-based version specified in this document. 0 0 1 0 2 DCE Security version, with embedded POSIX UIDs. 0 0 1 1 3 The name-based version specified in this document that uses MD5 hashing. 0 1 0 0 4 The randomly or pseudo- randomly generated version specified in this document. 0 1 0 1 5 The name-based version specified in this document that uses SHA-1 hashing. You get a version 4 (random) UUID by default QUuid::createUuid() but there are similar functions to create version 3 and 5 UUIDs. You can construct a QUuid object specifying all the components yourself to obtain a UUID of any variant or version.
  • QT5 c++ qdesigne custom widget bad resizing

    Unsolved
    2
    0 Votes
    2 Posts
    149 Views
    SGaistS
    Hi, Is that monitor a High-DPI monitor ? How do you determine the size of the LED widget ?
  • Strange memory allocation issues?

    Unsolved memory leak detection test
    4
    0 Votes
    4 Posts
    728 Views
    D
    @Christian-Ehrlicher said in Strange memory allocation issues?: @Dariusz said in Strange memory allocation issues?: Any idea why converting QString to stdString causes memory allocation issues? I don't know what you're trying to achieve - if you want to look for memory leaks use the appropriate tools but those two functions don't leak any memory. /edit: and btw: there is more than one new operator: https://en.cppreference.com/w/cpp/memory/new/operator_new Meh no luck, added other ones but failed to track it :/ // 1. Simple allocation void *operator new(std::size_t size) { if (mRecordData) { allocations++; total++; void *p = std::malloc(size); if (!p) { badAllocs++; totalBadAllocs += size; throw std::bad_alloc(); } totalSizeAllocated += size; return p; } return std::malloc(size); } // 2. Array allocation void *operator new[](std::size_t size) { return ::operator new(size); } // 3. No-exception allocation void *operator new(std::size_t size, const std::nothrow_t &) noexcept { if (mRecordData) { allocations++; total++; void *p = std::malloc(size); if (!p) { badAllocs++; totalBadAllocs += size; } return p; } return std::malloc(size); } // 4. Array no-exception allocation void *operator new[](std::size_t size, const std::nothrow_t &nt) noexcept { return ::operator new(size, nt); } #if __cplusplus >= 201703L // 5. Aligned allocation (C++17 onward) void *operator new(std::size_t size, std::align_val_t al) { if (mRecordData) { allocations++; total++; void *p = _aligned_malloc(static_cast<size_t>(al), size); if (!p) { badAllocs++; totalBadAllocs += size; throw std::bad_alloc(); } totalSizeAllocated += size; return p; } return _aligned_malloc(static_cast<size_t>(al), size); } // 6. Aligned array allocation (C++17 onward) void *operator new[](std::size_t size, std::align_val_t al) { return ::operator new(size, al); } #endif // Corresponding delete overloads void operator delete(void *p) noexcept { if (mRecordData) { deallocations++; total--; } std::free(p); } void operator delete[](void *p) noexcept { ::operator delete(p); } void operator delete(void *p, const std::nothrow_t &) noexcept { ::operator delete(p); } void operator delete[](void *p, const std::nothrow_t &) noexcept { ::operator delete(p); } #if __cplusplus >= 201703L void operator delete(void *p, std::align_val_t) noexcept { ::operator delete(p); } void operator delete[](void *p, std::align_val_t) noexcept { ::operator delete(p); } #endif Bummer! Just wanted a lightweight way of tracking my test allocations/memory footpring :c I know there is valgrind/other ones, but they are harder to set up for per-function tests/etc inside gtest as far as I can tell :/
  • QT Input Devices

    Unsolved
    2
    0 Votes
    2 Posts
    147 Views
    S
    @Christian-Ehrlicher any hint?
  • QAudioOutput becomes idle and stays idle when buffer underrun on MacOS

    Solved
    8
    0 Votes
    8 Posts
    2k Views
    M
    @johnco3 I am not using a pull mode I don't believe. I am using a timer that fires every 20ms and writes more data as it becomes available. I'm sorry.
  • QT CrossCompile for Jetson Nano

    Unsolved
    1
    0 Votes
    1 Posts
    535 Views
    No one has replied
  • Preventing cursor moving after text property is set

    Solved
    4
    0 Votes
    4 Posts
    595 Views
    S
    @SGaist this in indeed a very cool trick that works even better than I thought. I have added a custom property text2 that was set as the user property. This also means that I do not have to change the QDataWidgetMapper addMapping function, since that one requests the user property to begin with. Thank you very much for this sneaky/clever trick as @JonB points out :-)
  • Qt 6.6.0 OpcUA Debug

    Unsolved
    1
    0 Votes
    1 Posts
    140 Views
    No one has replied
  • Projectconfiguration Displayname

    Solved
    2
    0 Votes
    2 Posts
    164 Views
    R
    @Redman For anyone wondering: Simply create a <ProjectName>.pro.shared file and copy parts to share into the newly created file. Whitelist it in the .gitignore if needed and you're good.