Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.7k Posts
  • Passing QWheelEvents to child causes infinite loop

    Unsolved
    6
    0 Votes
    6 Posts
    465 Views
    jeremy_kJ
    @PhabSeals said in Passing QWheelEvents to child causes infinite loop: I also can't send the wheelEvent directly to the child object because there is no way of accessing it in the QApplication event filter because the QApplication does not know if widgetInFocus is a MyWidget object or not. Presuming that MyWidget is registered with the metaobject system, ie uses Q_OBJECT, either of the following will resolve this question: !strcmp(widgetInFocus->staticMetaObject().className(), "MyWidget"); qobject_cast<MyWidget *>(widgetInFocus) != nullptr;
  • How to resize and make the new size persistent in QSvgWidget?

    Unsolved
    2
    0 Votes
    2 Posts
    472 Views
    D
    @Emon-Haque, took a while to figure out that setMaximumSize(QSize(14, 14)) is what I need in the constructor!
  • Multiple QAction and using sender() to get which got selected?

    Solved
    10
    0 Votes
    10 Posts
    2k Views
    C
    Appreciate the help, I'll take all your suggestions and learn from them. Thank you!
  • Problem setting up Curl

    Solved
    4
    0 Votes
    4 Posts
    328 Views
    SGaistS
    The rules on Windows to avoid DLL hell are pretty simple: Deploy the dlls your application requires in the same folder as your executable (plugins like Qt's own can live in different folders though). Do NOT install any dll in system folders. This can have unexpected side effects and wreak havoc. Unless really required (most of the time it's not), do not modify the PATH environment variable.
  • QTableWidget Sorting

    Solved
    3
    0 Votes
    3 Posts
    346 Views
    P
    That was it, thank you!
  • How to redirect "system" call results directly to widget ?

    Unsolved
    2
    0 Votes
    2 Posts
    141 Views
    Christian EhrlicherC
    Use QProcess and read stdout/stderr.
  • modbus component. a lot of crc errors.

    Unsolved
    3
    0 Votes
    3 Posts
    490 Views
    P
    Qt 5.11.3 I receive data from different devices and problem is everywhere.
  • This topic is deleted!

    Locked Unsolved
    5
    0 Votes
    5 Posts
    12 Views
  • QRegularExpression and Unicode Blocks

    Unsolved
    2
    0 Votes
    2 Posts
    286 Views
    VRoninV
    From https://doc.qt.io/qt-5/qregularexpression.html For an overview of the regular expression syntax supported by QRegularExpression, please refer to the [...] pcrepattern man page And from that page: The long synonyms for property names that Perl supports (such as \p{Letter}) are not supported by PCRE, nor is it permitted to prefix any of these properties with "Is". Basically: Qt uses pcre in QRegularExpression and that library doesn't support those blocks
  • Why mainwindow can still showmaximized() after setFixedSize()?

    Unsolved
    3
    0 Votes
    3 Posts
    359 Views
    C
    Qt does that because you asked it to do contradictory things and it has to choose one. If you do not want the window maximized then do not call showMaximized() and hide the maximize widget (https://doc.qt.io/qt-5/qwidget.html#windowFlags-prop) to make it difficult for the user to do it.
  • Is it possible to give a QML file to a Qt app executable?

    Solved
    4
    0 Votes
    4 Posts
    330 Views
    M
    Your answers help me a lot, I will try this based on your example, thanks !
  • Reading continuous from Console in qt5

    Unsolved
    17
    0 Votes
    17 Posts
    4k Views
    JonBJ
    @SGaist I have tried to ask/suggest that to the OP several times now....
  • How to animate/change color of QPixmap/QImage/QPicture/whatever on mouseEvents?

    Solved
    10
    0 Votes
    10 Posts
    1k Views
    D
    @eyllanesc, hmm not bad: [image: c36e825c-6b45-47e3-b86d-e9c3c69c5461.gif] would be nicer if there's some easy way to add a QPropertyAnimation for color. Instead of svg file there should be some way to use path data, to avoid DOM traversing, directly and animate its color.
  • Why doesn't QAction enter into event/eventFilter?

    Solved
    4
    0 Votes
    4 Posts
    322 Views
    D
    @eyllanesc, posted as another question.
  • QTableWidget Column Hold More Than One Item

    Solved
    3
    0 Votes
    3 Posts
    154 Views
    P
    Oh, right. Thanks, I just tried it and it works exactly. Just put it in an if-statement to check if it's at the end of the array so I can see if I need a comma or not.
  • Add widget right aligned to a QTableWidget cell

    Solved
    46
    0 Votes
    46 Posts
    8k Views
    H
    @VRonin said in Add widget right aligned to a QTableWidget cell: I assume you mean setItemDelegateForRow and setItemDelegateForColumn. yes, I copied and pasted n forgot to modify before submitting. Thanks
  • How to pass argc and argv to MainWindow object

    Solved
    8
    0 Votes
    8 Posts
    3k Views
    Christian EhrlicherC
    How about looking at the QString documentation? QString::toLatin1(), QString::toUtf8() for example. And why do you need a char** at all? What are you trying to do?
  • KDGantt Chart Layout Help

    Solved
    3
    0 Votes
    3 Posts
    429 Views
    P
    I found it. I had to get access to the left pane and then set the width. Thank you for the help! view->leftView()->setMaximumWidth(100);
  • QTableWidgetItem will use a spinbox for editor automatically if setData is called

    Solved
    7
    0 Votes
    7 Posts
    1k Views
    jronaldJ
    @VRonin said in QTableWidgetItem will use a spinbox for editor automatically if setData is called: class IntLineEditCreator : public QItemEditorCreatorBase { public: IntLineEditCreator() = default; QWidget* createWidget(QWidget *parent) const override{ return new QLineEdit(parent); } QByteArray valuePropertyName() override{ return QByteArrayLiteral("text"); } }; then you can use it with something like: IntLineEditCreator* creator = new IntLineEditCreator; QItemEditorFactory *factory = new QItemEditorFactory; factory->registerEditor(QMetaType::Int, creator); factory->registerEditor(QMetaType::UInt, creator); tableWidget->delegate()->setItemEditorFactory(factory); connect(tableWidget,&QObject::destroyed,creator,factory{delete creator; delete factory;}); Awesome, thanks
  • How to get the correct QSqlError?

    Unsolved
    12
    0 Votes
    12 Posts
    2k Views
    D
    These errors also vary depending on which object I'm using (QSqlQueryModel or QSqlQuery ) and with a valid database. Here's the error I got with QSqlQueryModel: [image: eedc5564-2783-45a6-b2a1-4151d6fbc9f1.gif] To code is: else{ QSqlQueryModel sqlQuery; bool gotError = false; db.transaction(); for (int i = 0; i < statements.size(); i++) { auto trimmed = statements[i].trimmed(); if(trimmed.startsWith("--")) continue; sqlQuery.setQuery(trimmed); if(sqlQuery.query().isSelect()){ emit widget->logMessage("e,SELECT isn't allowed while executing multiple statements"); gotError = true; break; } else if(sqlQuery.query().lastError().type() != QSqlError::NoError){ emit widget->logMessage("e," + sqlQuery.query().lastError().text()); gotError = true; break; } } ... } so it's correct, NewTable exists. If I replace those code with these: else{ bool gotError = false; db.transaction(); for (int i = 0; i < statements.size(); i++) { auto trimmed = statements[i].trimmed(); if(trimmed.startsWith("--")) continue; sqlQuery.clear(); sqlQuery.prepare(trimmed); sqlQuery.exec(); if(sqlQuery.isSelect()){ emit widget->logMessage("e,SELECT isn't allowed while executing multiple statements"); gotError = true; break; } else if(sqlQuery.lastError().type() != QSqlError::NoError){ emit widget->logMessage("e," + sqlQuery.lastError().text()); gotError = true; break; } } ... } where sqlQuery is a global QSqlQuery, I get this error: [image: bda81e3f-6bf0-4b63-a7ee-e5815fd3b278.gif] that's a misleading error I got! Am I doing something wrong or it's an issue with SQLite? EDIT Looks like QSqlQuery doesn't need to be executed to get error. I've to check error immediately after sqlQuery.prepare(trimmed); and if there's no error then I should call sqlQuery.exec(). In a nutshell, Qt executes the query, and figures out the error, before I call exec.