Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.7k Topics 458.3k Posts
  • How to convert QIcon::fromTheme to Pixmap?

    Solved
    7
    0 Votes
    7 Posts
    1k Views
    K
    @mrjj said what does https://doc.qt.io/qt-5/qicon.html#isNull say ? No I'm on Windows, I use setThemeName. Thanks for the tip with isNull(), I completely overlooked it since it appeared to be working on the face of it (icons would show, they just wouldn't convert to pixmap), it turns out it was returning true in every case. I moved my search paths and set theme name code higher up in main.cpp, this changed isNull to false in every case. The program is huge (not mine) and main is about 1000 lines so I don't fully understand why that happened yet, but converting to QPixmap now works it seems. Thanks! I'll be back if it fails in my functions.
  • remove space around qToolButton

    Unsolved
    19
    0 Votes
    19 Posts
    2k Views
    mrjjM
    Hi Sadly no. If you want such things, make a custom button that does it. However, Qt has support for HIRES displays that do scaling etc. and QIcon can have hires version to be used on such displays https://doc.qt.io/qt-5/highdpi.html but this has nothing to do with you want icon to cover all of the button at all times :) That is not a hires thing, in my opinion :) here is example of custom button https://stackoverflow.com/questions/31742194/dynamically-resize-qicon-without-calling-setsizeicon It scales the cion to fit at any given time. As you can see its not much code.
  • Avoiding name clashes with Qmake if two files in project have the same name.

    Unsolved
    6
    0 Votes
    6 Posts
    756 Views
    mrjjM
    @sandro4912 hi yes since all output goes to the same folder, having files with the same names will overwrite each other .o file. So basically its just a bad idea that will come back and hurt you. :) Why have namespaces when they are not usefull. They are used to avoid name clash for types internally. Not to protect from name clash on files. at one point in time one could do CONFIG += object_parallel_to_source or CONFIG += object_with_source https://stackoverflow.com/questions/9450225/why-does-qmake-put-all-object-o-files-to-one-directory But Moc dont understand this so if Qt based classes, its a no go. I thought with the folder system and the namespace I can avoid long names. Is there really no way? What long names ?
  • QColorDialog doesn't preview alpha

    Unsolved
    1
    0 Votes
    1 Posts
    639 Views
    No one has replied
  • TableView, SQLite, QSqlRelationalTableModel

    Unsolved
    3
    0 Votes
    3 Posts
    279 Views
    C
    Thanks, will give that a shot... ( still learning the classes ). Thanks!
  • When Clicking Combobox The Whole Window Is Moved to That Location

    Unsolved
    3
    0 Votes
    3 Posts
    470 Views
    L
    @jsulm No because it is saying if it is not the box I want to be dragged then to not do anything essentially, currently it all works other than when i click a combo box it bugs out.
  • Using Community instead of Evaluation

    Unsolved
    1
    0 Votes
    1 Posts
    119 Views
    No one has replied
  • Is it a difference where I compile a code?

    Unsolved compile
    19
    0 Votes
    19 Posts
    2k Views
    Pablo J. RoginaP
    @TomNow99 I guess you may want to take a look at this library: lwext4 Although "The main goal of the lwext4 project is to provide ext2/3/4 filesystem for microcontrollers" documentation also mentions compilation for Windows. And then take a look at project ext4-browser which relies on that library to provide "a file-archiver like utility which can create, read and modify ext2/3/4 disks and disk images on Windows and Mac OS systems." although the GUI is written using wxWidgets framework. So getting back to my suggestion, I guess you might combine lwext4 library and the ext2read GUI to achieve your goal...
  • Wrong OpenGL viewport of widget inside QDockWidget

    Solved
    7
    0 Votes
    7 Posts
    642 Views
    Jaime02J
    I found the problem: There was missing a QOpenGLWidget::resizeEvent(event); statement at resizeEvent.
  • Help with deprecated code

    Solved
    6
    0 Votes
    6 Posts
    1k Views
    L
    OK, I see. I converted to QString which seems to fix the error.
  • grabWindow only grabs desktop background in macOS Catalina

    Solved
    3
    0 Votes
    3 Posts
    652 Views
    freddy311082F
    Awesome @jsulm... it works !!! Thank you very much !!!
  • Need help to create simple model for QTreeModelView

    Solved
    37
    0 Votes
    37 Posts
    5k Views
    Please_Help_me_DP
    Now when I have some MyModel I would like to write MyProxyModel which inherited by QAbstractProxyModel (I need to understand how they work that is why I don't want to use QSortFilterProxyModel for now). QAbstractProxyModel inherits QAbstractItemModel so as I understand I must implelement at least the following pure virtual methods from these both abstract models: int QAbstractItemModel::columnCount(const QModelIndex &parent = QModelIndex()) const QVariant QAbstractItemModel::data(const QModelIndex &index, int role = Qt::DisplayRole) const QModelIndex QAbstractItemModel::index(int row, int column, const QModelIndex &parent = QModelIndex()) const QModelIndex QAbstractItemModel::parent(const QModelIndex &index) const int QAbstractItemModel::rowCount(const QModelIndex &parent = QModelIndex()) const QModelIndex QAbstractProxyModel::mapFromSource(const QModelIndex &sourceIndex) const QModelIndex QAbstractProxyModel::mapToSource(const QModelIndex &proxyIndex) const Ok, I don't want to use any kind of a sorting I just want to wrap MyModel to MyProxyModel. In proxy model I just declare the same methods that my source model has and invoke these methods: h5proxymodel.h #ifndef H5PROXYMODEL_H #define H5PROXYMODEL_H #include <QAbstractProxyModel> #include <QSortFilterProxyModel> #include "h5model.h" class H5ProxyModel : public QAbstractProxyModel { Q_OBJECT public: explicit H5ProxyModel(QObject *parent = nullptr); ~H5ProxyModel(); QModelIndex mapFromSource(const QModelIndex &sourceIndex) const override; QModelIndex mapToSource(const QModelIndex &proxyIndex) const override; void setSourceModel(QAbstractItemModel *sourceModel) override; QAbstractItemModel* getSourceModel(); QModelIndex index(int row, int column, const QModelIndex &parent) const override; QModelIndex parent(const QModelIndex &index) const override; int rowCount(const QModelIndex &parent) const override; int columnCount(const QModelIndex &parent) const override; QVariant data(const QModelIndex &index, int role) const override; bool setData(const QModelIndex &index, const QVariant &value, int role) override; QVariant headerData(int section, Qt::Orientation orientation, int role) const override; bool insertRows(int position, int rows, const QModelIndex &parent = QModelIndex()) override; bool removeRows(int position, int rows, const QModelIndex &parent = QModelIndex()) override; bool hasChildren(const QModelIndex &parent = QModelIndex()) const override; void expand(const QModelIndex &parent); void collapse(const QModelIndex &parent); Qt::ItemFlags flags(const QModelIndex &index) const override; private: QAbstractItemModel* sourceModel; }; #endif // H5PROXYMODEL_H h5proxymodel.cpp #include "h5proxymodel.h" H5ProxyModel::H5ProxyModel(QObject *parent) : QAbstractProxyModel(parent) { } H5ProxyModel::~H5ProxyModel() { delete sourceModel; } QModelIndex H5ProxyModel::mapFromSource(const QModelIndex &sourceIndex) const{ if (!sourceIndex.isValid()) return QModelIndex(); return sourceIndex; } QModelIndex H5ProxyModel::mapToSource(const QModelIndex &proxyIndex) const { if (!proxyIndex.isValid()) return QModelIndex(); return proxyIndex; } void H5ProxyModel::setSourceModel(QAbstractItemModel *sourceModel){ this->sourceModel = sourceModel; } QAbstractItemModel* H5ProxyModel::getSourceModel(){ return this->sourceModel; } QModelIndex H5ProxyModel::index(int row, int column, const QModelIndex &parent) const{ return this->sourceModel->index(row, column, parent); } QModelIndex H5ProxyModel::parent(const QModelIndex &index) const{ return this->sourceModel->parent(index); } int H5ProxyModel::rowCount(const QModelIndex &parent) const{ return this->sourceModel->rowCount(parent); } int H5ProxyModel::columnCount(const QModelIndex &parent) const{ return this->sourceModel->columnCount(parent); } QVariant H5ProxyModel::data(const QModelIndex &index, int role) const{ return sourceModel->data(index, role); } bool H5ProxyModel::setData(const QModelIndex &index, const QVariant &value, int role){ return sourceModel->setData(index, value, role); } QVariant H5ProxyModel::headerData(int section, Qt::Orientation orientation, int role) const{ return sourceModel->headerData(section, orientation, role); } bool H5ProxyModel::insertRows(int position, int rows, const QModelIndex &parent){ return sourceModel->insertRows(position, rows, parent); } bool H5ProxyModel::removeRows(int position, int rows, const QModelIndex &parent){ return sourceModel->removeRows(position, rows, parent); } bool H5ProxyModel::hasChildren(const QModelIndex &parent) const{ return sourceModel->hasChildren(parent); } void H5ProxyModel::expand(const QModelIndex &parent){ static_cast<H5Model*>(sourceModel)->expand(parent); } void H5ProxyModel::collapse(const QModelIndex &parent){ static_cast<H5Model*>(sourceModel)->collapse(parent); } Qt::ItemFlags H5ProxyModel::flags(const QModelIndex &index) const{ return sourceModel->flags(index); } As you can see all that my proxy does is it redirects commands to source model. But all I see is header in tree view instead of a items (the right picture I see if I set source model to a tree view): [image: b30fd52f-a2f9-4466-83b8-a66cd89e5ede.png] Why my logic doesn't work?
  • How does the QTimer stop function work?

    Unsolved
    1
    0 Votes
    1 Posts
    120 Views
    No one has replied
  • QComboBox, height ?

    Solved
    2
    0 Votes
    2 Posts
    204 Views
    VRoninV
    https://doc.qt.io/qt-5/qstyle.html#sizeFromContents
  • How to use/include the QtNetwork Module

    Unsolved
    8
    0 Votes
    8 Posts
    3k Views
    VRoninV
    Last time I used the VS Tools (that was with VS 2013) it required to start a project from scratch, not sure if they introduced a "convert to qt project" feature since
  • 1 Votes
    1 Posts
    595 Views
    No one has replied
  • Debugging QComboBox delegate freezes System

    Unsolved
    1
    0 Votes
    1 Posts
    127 Views
    No one has replied
  • Qt label image display always has different size from original image

    Unsolved
    2
    0 Votes
    2 Posts
    664 Views
    VRoninV
    Try setting the scaledContents property of QLabel to true
  • Using Caffe Model with C++ QT Application

    Unsolved
    3
    0 Votes
    3 Posts
    389 Views
    I
    Thanks for helping. I am trying the github link. Actually the reason behind using MTCNN is to detect profile faces also on thermal images. I want to try whether MTCNN can do it or not?
  • This topic is deleted!

    Unsolved
    3
    0 Votes
    3 Posts
    42 Views