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?
i can do that from text editor
chmod +x or chmod + 777 did not help -
Hi @JacobNovitsky,
How to set needed permission so I can edit qt headers from qt creator?
Well, first off, you shouldn't! Editing those files can very easily cause strange and hard-to-trace failures in your application as the headers no longer match the Qt libraries you'll be linking against. That you don't already know how to change those permissions suggests that you shouldn't be doing it.
That said, for the sake of answering the question... if you must then:
sudo chmod a+w /usr/include/x86_64-linux-gnu/qt5/QtWidgets/qmainwindow.h
But again, I strongly recommend against it.
Out of curiosity, why do you want to do this?
Cheers.
-
@Paul-Colby hi, thanks for reply
you can refer to other question for today, I want to make chain of headers pre-compiled to reduced building/compilation time -
@JacobNovitsky said in How to set needed permission so I can edit qt headers from qt creator?:
I want to make chain of headers pre-compiled to reduced building/compilation time
This absolutely does not require any modification of header files outside your own project's files (and generally not even those).
-
@ChrisW67 As I understood guides and youtube videos:
[1] set needed headers to pro.file below lines
PRECOMPILED_HEADER = Static_lib.h \ /home/supernova/Qt/6.2.4/Src/qtbase/include/QtWidgets/QDialog /home/supernova/Qt/6.2.4/Src/qtbase/include/QtWidgets/QStandardItemModel /home/supernova/Qt/6.2.4/Src/qtbase/include/QtWidgets/QMainWindow /home/supernova/Qt/6.2.4/Src/qtbase/include/QtWidgets/QWidget
[2] each header and inner header needs to get wrapped like this
#pragma once #ifndef QDIALOG_H #define QDIALOG_H #if defined __cplusplus #include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qwidget.h> #endif QT_REQUIRE_CONFIG(dialog); #pragma once
-
@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.
-
C Christian Ehrlicher referenced this topic on
-
C Christian Ehrlicher referenced this topic on
-
C Christian Ehrlicher referenced this topic on