Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.5k Topics 457.3k Posts
  • ActiveQt: Export array of QObjects to OLE

    Unsolved
    5
    0 Votes
    5 Posts
    1k Views
    hskoglundH
    Hi, sorry about ".. give me a few hours .." a bit too optimistic :-) Anyway when you said " ... not possible" I just had to look into it: As yet I haven't got a finished example. but I've solved the main riddle, how to export/expose a SAFEARRAY of IDispatch* chaps: in the old days when using Visual Studio you could pretty much could export anything from your C++ to OLE, but it was a lot of fiddling with the .idl input file to the MIDL compiler (that's the Microsoft tool that creates a.tlb file from an .idl file). When using Qt you get all of this for free (through the idc.exe tool, that creates the .idl file from your .exe file) but for a price: you lose the flexibility of exporting all kinds of weird stuff to OLE, instead you are restricted to a subset of properties and data types, for example you can only export a SAFEARRAY of VARIANTs (through a QVariantList). The list of valid OLE types is in Qt's source if you want to see it. But I take this restriction anyday because it makes dealing with OLE so much easier. Unless of course you want to bypass those restrictions, like in your example above. So to export a SAFEARRAY of IDispatch* pointers, we have to find a way past the strict eyes of Qt's idc.exe compiler. I use 2 #defines and C's text preprocessor to "edit" the .idl file after it is written by the idc.exe program. (Remember there's no .idl file to patch, it is rewritten completely after the linking step.) I made an example SafeArrayTest, a simple widget .dll, here's the relevant part: ... `#include <comdef.h> // get OLE_COLOR from here class SafeArrayTest : public QWidget { Q_OBJECT Q_CLASSINFO("ClassID", "{DF168452-A2CD-4AAB-A982-6B9840E74661}") Q_CLASSINFO("InterfaceID","{616F6205-31C5-4410-A74E-8B81C76FAFE2}") Q_CLASSINFO("EventsID", "{E1816BB3-1F5D-4A31-9855-E6BA432055F3}") Q_PROPERTY( OLE_COLOR dispatchArray READ dispatchArray ) ... So we have a dispatchArray property of the type OLE_COLOR (which is kosher for the idc.exe compiler) but then after idc.exe has created the .idl we pass along 2 #defines to the command line of Microsoft's MIDL compiler, by adding this to the .pro file: ... # expect our OLE property to be named "dispatchArray" with the dummy type OLE_COLOR QMAKE_IDL = midl /D OLE_COLOR=SAFEARRAY /D dispatchArray=(IDispatch*)dispatchArray Now, if I create a simple Visual Basic program and add a reference to the SafeArrayTest.dll, Visual Basic says that the property dispatchArray is an Array of Objects. I haven't finished that test program yet, but at least the OLE exposing is solved I think... I'll post again sooooon..
  • This topic is deleted!

    Unsolved
    3
    0 Votes
    3 Posts
    59 Views
  • 0 Votes
    5 Posts
    1k Views
    XequtorX
    Thanks. I will try to set the variables in the model. Best Regards, Ahmed
  • Convert QSerialPort Read To Int

    Solved
    9
    0 Votes
    9 Posts
    2k Views
    SGaistS
    handheldCOM->peek(1) != QLatin1Char('A') might be simpler.
  • PyQT4: QPushbutton icons and button name

    Unsolved
    7
    0 Votes
    7 Posts
    2k Views
    S
    @jsulm thanks for the help.
  • Error's including a Read Function in mainwindow

    Unsolved
    5
    0 Votes
    5 Posts
    3k Views
    jsulmJ
    @RIVOPICO What is "MainWindow::Reading"? Wasn't the name of the method "MainWindow::Read" before? This is really basic: // In header file public slots: void Read(QString); // in cpp file void MainWindow::Read(QString Filename) {...}
  • QTDeclarativeView and QTWebview

    Unsolved
    2
    0 Votes
    2 Posts
    483 Views
    jsulmJ
    @Melvin Did you see http://doc.qt.io/qt-5/qtquick-porting-qt5.html ? QDeclarativeView -> QQuickView QWebView -> http://doc.qt.io/qt-5/qwebengineview.html
  • 0 Votes
    10 Posts
    2k Views
    joeQJ
    @joeQ I am so stupid. i cost two days to save it. tried some wrong way. I found this doc helpful. now, i list the key wrolds QPen::setCosmetic QGraphicsItem::ItemIgnoresTransformations You can read them from Qt manual.
  • RS-232 signals inverted with QSerialPort

    Unsolved
    6
    0 Votes
    6 Posts
    2k Views
    R
    The odds of the signal levels being inverted are very unlikely. You mentioned you are using a PC scope. My guess is you have the gnd/signal connections swapped and this would make it look inverted. Could be a software setting that inverts the signal too. A simple way to test this is to connect an AA battery to the input as you know which ends of the battery are positive and negative. I would suggest replacing your 'device' with another computer that has a serial port and some sort of serial terminal (like Hyperterminal). It sounds like it is working but there is something wrong which is why you started looking at this with a scope. If you have the time you could write a software simulator that would emulate the hardware you are trying to talk to so you can bypass all the clumsy stuff (like USB-Serial adapters, cables, actual device, ...).
  • Qt 5.8 SCXML metadata

    Unsolved
    3
    0 Votes
    3 Posts
    620 Views
    larry104L
    Is the visual chart editor part of qtcreator or a standalone tool ? That's worth upgrading ;-) edit - I found the answer here
  • Does QtMultimedia work on Linux?

    Unsolved
    5
    0 Votes
    5 Posts
    3k Views
    SGaistS
    Hi, It really looks like you are missing the dev packages, can you double check your installed packages ?
  • Get Screenshot on MacOS

    Unsolved
    2
    0 Votes
    2 Posts
    426 Views
    beeckscheB
    Hi @UndeadBlow, maybe this helps: http://doc.qt.io/qt-5/qtwidgets-desktop-screenshot-example.html
  • Pull apart String

    Unsolved
    5
    0 Votes
    5 Posts
    1k Views
    Chris KawaC
    Please consider splitRef() instead of split(). It does not make copies. Also if you only want one part of the string take a look at section().
  • QStringList question

    Solved
    5
    0 Votes
    5 Posts
    1k Views
    VRoninV
    @Wieland said in QStringList question: another reason to avoid Qt's container classes A bit drastic for a solution... I tend not use range based for for any Qt container Sorry, I was too generic myself here, I mean: I tend not use range-based-for for any non const (or non const-able with something like std::as_const) Qt container
  • Resources files in Qt

    Solved
    4
    0 Votes
    4 Posts
    2k Views
    ?
    The Qt way is to create a *.qrc file and pass it to Qt's resource compiler. If you use Qt Creator and qmake, then all the complexity will be hidden from you. This way works on all platforms (operating systems / compilers) that are supported by Qt. To learn more about resource handling in Microsoft Visual Studio 2015, see Resource Files (Visual Studio).
  • Including .h files in a new project

    Solved
    3
    0 Votes
    3 Posts
    516 Views
    tomyT
    @Wieland said in Including .h files in a new project: Hi! Copy the files into your project's directory. Never touch the Qt directory. :-) Good remark, thanks, I will always do that.. :-)
  • QPrinter fail in save pdf with japanese characters

    Unsolved
    11
    1 Votes
    11 Posts
    1k Views
    ?
    On Windows 7, it fails for me, too.
  • Why my extra compiler don't appear

    Unsolved
    1
    0 Votes
    1 Posts
    308 Views
    No one has replied
  • Widgets inside another widget should resize

    Unsolved
    11
    0 Votes
    11 Posts
    2k Views
    Pradeep KumarP
    Hi, Thanks guys.
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    13 Views
    No one has replied