Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.1k Topics 454.7k Posts
QtWS25 Last Chance
  • Drag-and-drop row from one table to a single cell of another table

    Solved
    6
    0 Votes
    6 Posts
    389 Views
    Please_Help_me_DP
    I solved my problem by reimplementing MyTableView::dropEvent(QDropEvent *event). Here it is: void MyTableView::dropEvent(QDropEvent *event){ const QMimeData *mime = event->mimeData(); QStringList typeList = model()->mimeTypes(); if (typeList.isEmpty()) return; int sourceRow, sourceCol; QByteArray encodedData = mime->data(typeList[0]); // retrieve first row and col from first selectem item QDataStream stream(&encodedData, QIODevice::ReadOnly); stream >> sourceRow >> sourceCol; QTableView* sourceTableView = qobject_cast<QTableView*> (event->source()); // get tableview from item goes if (sourceTableView == nullptr) return; // as a result we have source table view, current table view, row and col of dragged item. That is enough to process dragged data and paste it to current model }
  • Model/View and Dock Widgets: a menu conundrum

    Solved
    7
    0 Votes
    7 Posts
    383 Views
    P
    OK, so I just connected QApplication::focusChange to a slot in the main window where I ask the question "is the widget that now has focus a view of the type I am interested in?" If yes, I change the related menus accordingly. The "Ah Ha!" moment for me indeed was to think about the views, not the docks. I first tried installing an event filter on the views to look for FocusIn events, which works, but even that is unnecessary given the focusChange api available from the QApplication.
  • QAbstractListModel populated in a Worker Thread (not the GUI one)?

    Unsolved
    11
    0 Votes
    11 Posts
    1k Views
    Christian EhrlicherC
    @mbruel said in QAbstractListModel populated in a Worker Thread (not the GUI one)?: Well I don't see how to manage that if it's the Working Thread that updates the data... Doing some synchronisation in order to achieve it would be just less efficient than letting the main thread updating the data... Correct, therefore my recommendation - don't try it :)
  • Mac vs Windows scaling (same app much smaller on Windows)

    Solved
    2
    0 Votes
    2 Posts
    1k Views
    jandymanJ
    It turns out the solution to this is simple, though I had to read a whole bunch of confusing descriptions of scalability. It really should be easier to find. And the Qt support pages on the topic could be less confusing. https://stackoverflow.com/questions/41331201/pyqt-5-and-4k-screen Put this in your setup code before creating the QGuiApplication, to support High DPI scaling on Windows: os.environ["QT_AUTO_SCREEN_SCALE_FACTOR"] = "1" sys.argv += ['--style', 'fusion'] app = QGuiApplication(sys.argv) The font scaling ends up a little bit different, but that is acceptable for my use case. For C++ users, look here: https://doc.qt.io/qt-5/qtquickcontrols2-highdpi.html Whew! I was getting nervous about my decision to create this cross platform UI.
  • How can I access json data at c++ code in qml?

    Unsolved
    2
    0 Votes
    2 Posts
    417 Views
    raven-worxR
    @taedooly said in How can I access json data at c++ code in qml?: does QJsonObject type support direct access in qml? QML converts the QVariantMap type to a JSON object. So simply call QJsonObject::toVariantMap() and pass it to on
  • Minimal SQL program that fails, what is wrong with it

    Unsolved
    7
    0 Votes
    7 Posts
    746 Views
    O
    I guess so, thank you for your replies.
  • Constructing a std::filesystem::path from a QString

    Unsolved
    4
    0 Votes
    4 Posts
    2k Views
    Christian EhrlicherC
    @Perdrix said in Constructing a std::filesystem::path from a QString: it's just that I've been bitten before by stuff that felt like it ought to work but didn't! Still no clear answer :) When the path is properly constructed I don't see what should go wrong here.
  • Is it ok? - QStandardItemModel and ownership of item

    Solved
    2
    0 Votes
    2 Posts
    371 Views
    Christian EhrlicherC
    Ownership and qobject parent / child relationship are two similar but different things. Just because an object takes ownership of another object there is not need that one is the parent of the other.
  • Update Class Value using Slider

    Solved
    8
    0 Votes
    8 Posts
    307 Views
    Christian EhrlicherC
    'widget' is a really bad name when you want to use findChild. Also why do you search for a QObject when you case it to a OSGWidget later on? Why not directly searching for a OSGWidget?
  • QT framework

    Solved
    2
    0 Votes
    2 Posts
    145 Views
    Christian EhrlicherC
    Use the Qt online installer to use the official binaries instead some third party stuff
  • How to create a thumbnail from a video using libvlc Qt vlc-qt

    Unsolved
    2
    0 Votes
    2 Posts
    793 Views
    JonBJ
    @devillIsHeree Did you try any Googling for, say: Qt vlc-qt thumbnail ? E.g. Start from the comments to https://stackoverflow.com/questions/31448313/video-preview-image-using-vlc-qt-or-libvlc-directly, https://forum.videolan.org/viewtopic.php?t=148937, and several others.
  • How to set window flags in QTDesigner

    Unsolved
    1
    0 Votes
    1 Posts
    233 Views
    No one has replied
  • How to play video backwards in qt using vlc-qt libvlc

    Unsolved
    1
    0 Votes
    1 Posts
    288 Views
    No one has replied
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    13 Views
    No one has replied
  • 0 Votes
    5 Posts
    441 Views
    O
    just detected that myself, thanks!
  • Deferred function call using QTimer.

    Solved
    6
    0 Votes
    6 Posts
    1k Views
    JonBJ
    @SGaist , @Helg1980 Sorry, you can see from what I wrote I just missed the this parameter. My bad.
  • Can't get going with QML, Python and QT Creator on Mac OS

    Solved
    7
    0 Votes
    7 Posts
    875 Views
    SGaistS
    AFAIK, you can reuse the same concepts that are used for C++ with some language adaptation.
  • Getting error 42601 when running procedure in PostgreSQL

    Solved sql
    1
    0 Votes
    1 Posts
    1k Views
    No one has replied
  • How to use signal from QPushButton to Main.cpp

    Unsolved
    2
    0 Votes
    2 Posts
    147 Views
    Christian EhrlicherC
    @Nocturnal said in How to use signal from QPushButton to Main.cpp: static variables What do you mean with this? Signal/slots need objects. See the documentation.
  • How to make QList const from outside

    Solved
    12
    0 Votes
    12 Posts
    648 Views
    Christian EhrlicherC
    @Cocojambo said in How to make QList const from outside: Can I prohibit copying reference and cloning the source array as result in any way from my class? No - it's a copy so the 'user' can do what he wants.