Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.4k Topics 456.4k Posts
  • About Q_OBJECT question

    Unsolved
    4
    0 Votes
    4 Posts
    245 Views
    jeremy_kJ
    @Pl45m4 said in About Q_OBJECT question: Here are some "rules" and how it works: https://doc.qt.io/qt-6/metaobjects.html I suspect that OP is asking about using moc output in a single source file executable. The link above hints at a #include method, but doesn't provide an example. This technique is used in the autotests, but I don't know if I've ever seen natural language documentation. For instance, https://code.qt.io/cgit/qt/qtbase.git/tree/tests/auto/corelib/kernel/qobject/tst_qobject.cpp?h=6.7#n8838 Here's an example usage, that should work with qmake or cmake and the appropriate automoc syntax. example.cpp: #include <QObject> class C : public QObject { Q_OBJECT }; #include "example.moc"
  • C2491 Error using QT_INIT_METAOBJECT

    Locked Unsolved
    2
    0 Votes
    2 Posts
    211 Views
    Christian EhrlicherC
    Dupe of https://forum.qt.io/topic/154289/c2491-smtpclient-staticmetaobject-definition-of-dllimport-static-data-member-not-allowed/
  • QSettings mismatch when read by two different classes

    Solved
    9
    0 Votes
    9 Posts
    537 Views
    P
    @Axel-Spoerl Sure, although the only way to change the settings is via this one gui page. Thanks
  • minimal mapboxgl application does not show map

    Unsolved
    5
    0 Votes
    5 Posts
    944 Views
    Ronel_qtmasterR
    You can ignore ssl errors and go ahead
  • moc file not found

    Unsolved
    17
    0 Votes
    17 Posts
    3k Views
    C
    @rpieket The file names in the PRO file do not match those in your post. Simple fix so that qmake now finds files. A Qt test is just another Qt program, following all the same rules. It is just that the Test Lib writes main() for you to allow it to provide a lot of plumbing for you behind the scenes. If you have the test class declaration in a separate header, as in this case, then that header should be listed in the PRO file HEADERS variable and not in the source file as an #include "blah.moc". No longer get: make: *** No rule to make target `testqstring.moc', needed by `testqstring.o'. Stop The QT variable in the PRO file needs QT += testlib so that the test Lib elements are included at compile and link time. Rerun qmake after changing the PRO file No longer get: ./Test_with_qmake/main.cpp:2:10: fatal error: 'QTest' file not found Remaining problems are to do with the construction of the sources and not qmake. main.cpp needs to #include "qteststring.h" so that the QTEST_MAIN macro expansion, which references TestString, knows what the class looks like. Test compiles
  • QWebEngineView crashes when app shuts down

    Unsolved
    5
    0 Votes
    5 Posts
    297 Views
    SGaistS
    @whatabout can you provide a minimal compilable example of your crashing application ?
  • zooming in qpdfview is slow and causes flickering on touch screen

    Unsolved
    1
    0 Votes
    1 Posts
    135 Views
    No one has replied
  • 0 Votes
    11 Posts
    1k Views
    S
    @Pl45m4 I tried another thing now. Just using the group as way of organizing but setting a qgraphicsrectitem as parent of the qgraphicsitem group. On mouse release i position the qgraphicsrectitem above the groupitem: if(DragSelectionInProgress == true){ qDebug() << "SelectionInProgress" << GroupSelectionRect; //Erstelle eine Liste aller selecteten items die nicht das grouprect sind und füge alle items dieser Liste dem grouprect hinzu if(GroupSelectionRect){ QList<QGraphicsItem *> selectedItems = this->selectedItems(); QList<QGraphicsItem *> itemsToAdd; foreach(QGraphicsItem *item, selectedItems) { if(item != GroupSelectionRect && item != SelectionRectPixItem) { itemsToAdd.append(item); } } if(itemsToAdd.count() > 1){ foreach(QGraphicsItem *item, itemsToAdd) { // Check if the item is a pixmap item or a rect item ResizablePixmapItem *rectItem = qgraphicsitem_cast<ResizablePixmapItem *>(item); if(rectItem){ rectItem->setShouldDrawHandles(false); rectItem->drawHandlesIfNecessary(false); //rectItem->setParentItem(SelectionRectPixItem); } GroupSelectionRect->addToGroup(item); } GroupSelectionRect->setParentItem(SelectionRectPixItem); SelectionRectPixItem->setRect(GroupSelectionRect->boundingRect()); //GroupSelectionRect->setSelected(true); } } DragSelectionInProgress = false; }else{ } QGraphicsScene::mouseReleaseEvent(event); } I can calculate exactly how many pixel the qgraphicsrectitem is resized, but how do i apply this to the group? I want the graphicsitemgroup to mimic the proportions of the qgraphicsrectitem. It should only resize, but stay anchored in the corner that is not moved. The green outline below is the groupitem, the handles are from the qgraphicsrectitem laying above: [image: a352aeae-50b6-495e-8f7b-50ca19c66fff.png] [image: b98135cf-cea6-4cf4-88c8-cc4179d32f3e.png]
  • Is there a way to display pictures real time in Qt?

    Unsolved realtime diplay delay
    5
    0 Votes
    5 Posts
    805 Views
    jsulmJ
    @JonB Same applies to flies :-D
  • Outsourced License Question

    Unsolved
    2
    0 Votes
    2 Posts
    176 Views
    jsulmJ
    @KidBuu You should ask Qt Company directly, this is user forum
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    18 Views
    No one has replied
  • 0 Votes
    3 Posts
    573 Views
    O
    @jsulm Indeed! Thank you for your reply.
  • QT C++ application is crashing at end of a method "}"

    Unsolved
    6
    0 Votes
    6 Posts
    444 Views
    S
    If you are on Windows, my experience is that the debugger most of the time points to the line after the current one. Which might mean that it actually crashed in the line before. But destructors is also a good guess.
  • why my qt5.15.2 when debug always crash

    Unsolved
    6
    0 Votes
    6 Posts
    493 Views
    jsulmJ
    @tegarrti Can you post the whole log when you're starting the app? Do you have any other Qt installations/libraries on this system?
  • Qt Print Dialog won't open

    Unsolved
    10
    0 Votes
    10 Posts
    585 Views
    SGaistS
    Hi, @cadol001 said in Qt Print Dialog won't open: @Christian-Ehrlicher that is exactly why I cannot use exec() #include "mainwindow.h" #include <QApplication> #include <QPrinter> #include <QPrintDialog> int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.show(); QPrinter printer; QPrintDialog* printDialog = new QPrintDialog(&printer, 0); printDialog->setAttribute( Qt::WA_DeleteOnClose ); printDialog->open(); return a.exec(); } All I did was put this snippet in the default widgets project. Switching out open() with exec() just magically works. I just can't use exec. Thanks I replaced MainWindow by QMainWindow and tested both printDialog->open() and printDialog->exec() and both worked fine. With Qt 6.6.0.
  • QSqlDatabase::select() fetches no data

    Solved
    11
    0 Votes
    11 Posts
    586 Views
    SGaistS
    @MasterQ Hi, A QSqlTableModel is a QSqlQueryModel which uses QSqlQuery. When you call setTable, a query is done to retrieve the table's field information, thus the connection must be opened.
  • PLEASE help me with C++ code analysis

    Unsolved
    8
    0 Votes
    8 Posts
    782 Views
    A
    @JonB Sorry, the code is a TEST "pointing" to same task... It looks as there is no way to skip "two level" code - either using "connect " and "switch" or multi slot approach with each "connect" a slot to task. Actually the idea was silly from get go. It is just a matter which will be easier to add / maintain. Thanks for your comments, appreciate your very constructive help.
  • Qt6 QCalendarWidget days too wide

    Unsolved
    3
    1 Votes
    3 Posts
    203 Views
    W
    @hskoglund I think in my case it may be a response to the scale factor. My Linux distro is configured for a 2X scale of all fonts. If so this could mean that the day cell's size is being incorrectly calculated.
  • Qt Creator C++ folding region

    Solved
    19
    0 Votes
    19 Posts
    6k Views
    Q
    I agree wiht it. folding region could let codes look neat and organized without having to create more meaningless funtions and files and jump between them. I saw someone use #pragma region RegionName{ #pragma endregion} to fold codes.and enter text "-Wno-unknow-pragmas" in Tools->Options->C++->Code Model->Build-system warings(Paul)-> Build-system warnings->Copy->(give the configuration name)->(Choose your configuration)->(tick) Use diagnostic flags from build system, to avoid generating warnings.
  • QTreeView item expansion

    Unsolved
    4
    0 Votes
    4 Posts
    5k Views
    L
    @aatwo Did you receive a solution?