Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.4k Topics 456.5k Posts
  • Translations

    3
    0 Votes
    3 Posts
    1k Views
    G
    Thanks for the hint I'll give it a try
  • Call a function of the program from a website, is it possible?

    10
    0 Votes
    10 Posts
    4k Views
    D
    I make something like this: On page (JS): @ onclick="sender.clicked( 1 );" @ On Qt: @ //On Load Page: ... ui->webView->page()->mainFrame()->addToJavaScriptWindowObject("sender", this); ... void WebPage::clicked(int codigo) { ... } @
  • Get Duration of .Mp3/.Avi file without using QMediaPlayer

    6
    0 Votes
    6 Posts
    6k Views
    M
    [quote author="Code_ReaQtor" date="1353980381"]You need to parse the file then compute for the duration. This "link":http://www.codeproject.com/Articles/8295/MPEG-Audio-Frame-Header may help you.[/quote] Why re-invent the wheel when MediaInfo does it all and not only for MP3 files, but for pretty much any audio/video format in existence? Unless you do this for your own education, I don't see much reason. Detecting the "duration" of MP3 files is especially difficult, because there is NO global header in a MP3 file, which could tell you the duration (or total frame count). Unless you want to parse all MP3 frames in the file (slow!) you might be able to guesstimate the duration from the file size and the bitrate (can be parsed from the first frame, for example). But that can only work with strict CBR files, it will fail horribly with VBR files. With VBR files you might be able to do something with the Xing header, if present, though...
  • Display image in QT

    4
    0 Votes
    4 Posts
    2k Views
    D
    Here a simple example code: @ QGraphicsScene scene; QLabel *gif_anim = ui->lbIcone; QMovie *movie = new QMovie(":/imagens/32/loading_2.gif"); gif_anim->setMovie(movie); movie->start(); @ It's works fine to me, and show some animated GIFs!
  • 0 Votes
    4 Posts
    2k Views
    K
    [quote author="alexisdm" date="1353974018"]QTcpSocket::write writes the data into a buffer which is not limited in size. To know when the data is actually sent, you can use the bytesWritten(int) signal. [/quote] Thanks alot this helped. There are still bytes written for a while. This might be around 20k. Since the amount per second is relatively small (<1k/sec) it takes some time. I guess this might be certainly dependent on OS. I am using now a counter for the number of bytes indicated by bytesWritten signal. When this number does not increase anymore also the method bytesToWrite of QTcpSocket shows an increasing number. A bit patience missing on my side would have solved it already :-) [quote author="ChrisW67" date="1353998233"]If the client is not closing the original connection then there's no indication to the server that the client does not want to receive more information on the connection. Sounds like you have a faulty client.[/quote] That reflects my opinion, but it is arguable. Unfortunately, this is one application. The question is how many are around doing the same thing. My guess is that a different lib is used. With Qt I could not reproduce.
  • Regarding src folder

    3
    0 Votes
    3 Posts
    1k Views
    S
    Surely i will post it .
  • QMessageBox inside a QGraphicsScene

    1
    0 Votes
    1 Posts
    793 Views
    No one has replied
  • [SOLVED] Custom QVariant crash on drag in QTreeView

    5
    0 Votes
    5 Posts
    6k Views
    M
    Perfect, thanks!!!
  • Very simple C++ question - synchronous file download

    3
    0 Votes
    3 Posts
    3k Views
    C
    Having the signal-slot implementation early on the contructor class is wrong as it will act as asynchronous. You may use QEventLoop to make things synchrous while making your GUI (for example) responsive. @http->setHost(Host); http->get(RemoteFile); QEventLoop loop; QObject::connect(reply,SIGNAL(readyRead()),&loop,SLOT(quit())); loop.exec(); //download here http->readAll();@ Why dont you use QNetworkAccessManager by the way? QHttp is already obsolete. From QHttp documentation: bq. This class is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.
  • QT 4.8.3 Installation error

    5
    0 Votes
    5 Posts
    2k Views
    N
    Thank you all for your help.
  • Help With Qt Programming; Approaching a Program

    6
    0 Votes
    6 Posts
    2k Views
    A
    Thank you so much for your help, I finally have a way of approaching this program. I don't have anymore questions for now, maybe I will once I start implementing the functions, classes, etc. later in the afternoon. Thank you for your help once again.
  • Open Source / Source codes for Waveform viewer in Qt

    7
    0 Votes
    7 Posts
    7k Views
    S
    Thanks. Good idea to try QwtPlotIntervalCurve. Any idea how to add movable markers to plot ? One more important point: The GUI should contain in it Tree View like items and opposite each item rectangle-like wave ( regions ). Can that be done using QwtPlotIntervalCurve ( it adds on the left standard axis with equally spaced linear interval values, but I need tree fashioned axis like in the second attached picture )? I searched qt-apps.org, qt-prop.org, kde-apps.org, but no such elements found. I know there are plenty of complex open source projects.Maybe there is an open source project with such gui elements ? Thanks in advance for your help.
  • 0 Votes
    2 Posts
    3k Views
    J
    Okay, i could fix it by my own. My mistake was the usage of the out-of-box macro Q_SCRIPT_DECLARE_QMETAOBJECT() (Qt 4.8.1) There is nothing wrong with it, despite the fact, that behind this macro, there is a boiler plate constructor for script objects which does not set the default prototype! Maybe you could see this as a bug? I don't know. But more important, to use the defaultPrototype feature in the way I used it above, either you have to define your own constructor for script objects or, a more elegant way, define your own Q_SCRIPT_DECLARE_QMETAOBJECT() macro. Below there is my suggestion with defaultPrototype-Support: original Q_SCRIPT_DECLARE_QMETAOBJECT() macro: @ #define Q_SCRIPT_DECLARE_QMETAOBJECT(T, _Arg1) template<> inline QScriptValue qscriptQMetaObjectConstructor<T>(QScriptContext *ctx, QScriptEngine *eng, T ) { _Arg1 arg1 = qscriptvalue_cast<_Arg1> (ctx->argument(0)); T t = new T(arg1); if (ctx->isCalledAsConstructor()) return eng->newQObject(ctx->thisObject(), t, QScriptEngine::AutoOwnership); QScriptValue o = eng->newQObject(t, QScriptEngine::AutoOwnership); o.setPrototype(ctx->callee().property(QString::fromLatin1("prototype"))); return o; } @ improved suggestion with defaultPrototype-support: @ #define Q_SCRIPT_DECLARE_QMETAOBJECT_DEFAULT_PROTOTYPE(T, _Arg1) template<> inline QScriptValue qscriptQMetaObjectConstructor<T>(QScriptContext *ctx, QScriptEngine eng, T ) { _Arg1 arg1 = qscriptvalue_cast<_Arg1> (ctx->argument(0)); T t = new T(arg1); if (ctx->isCalledAsConstructor()) { QScriptValue proto = eng->defaultPrototype(qMetaTypeId<T>()); QScriptValue u = eng->newQObject(ctx->thisObject(), t, QScriptEngine::AutoOwnership); u.setPrototype(proto); return u; } QScriptValue o = eng->newQObject(t, QScriptEngine::AutoOwnership); o.setPrototype(ctx->callee().property(QString::fromLatin1("prototype"))); return o; } @ All needed voodoo is to ask the ScriptEngine for the defaultPrototype using the template parameter T (line 7) and setting it as prototype of the newly created script object (line 9) Maybe it is useful for someone out there!
  • How to create a QComboBox that displays widgets?

    4
    0 Votes
    4 Posts
    3k Views
    D
    You are welcome. Hope you are having success with your project.
  • QDomDocument XPath

    2
    0 Votes
    2 Posts
    5k Views
    L
    Please see "QXmlQuery":http://qt-project.org/doc/qt-4.8/qxmlquery.html documentation for details and examples.
  • Stardelegate example - how to read data from my own widget item

    2
    0 Votes
    2 Posts
    1k Views
    N
    Hello I found solution for my problem. That is for example: @val = IconPainter(qVariantValue<IconPainter>(ui->table->item(0 + i*3, 0)->data(0))).getState();@ I hope that's optimal solution :)
  • [solved] QObject::children problem

    10
    0 Votes
    10 Posts
    6k Views
    B
    Typical C++ happyness: The point of crash and the error message was totally misleading (for me) :) Thanks to all!
  • QTreeWidget - Changing the width of the selection rect of an item

    3
    0 Votes
    3 Posts
    1k Views
    D
    Hi Gerolf, Thank you for this quick answer. So let's programing ... Regards
  • Changing the fore color of a progress bar

    3
    0 Votes
    3 Posts
    5k Views
    G
    Thank you, it was very helpful.
  • Qt with HansBoehm gc

    2
    0 Votes
    2 Posts
    1k Views
    Q
    As i understand from "Conservative GC Algorithmic Overview":http://www.hpl.hp.com/personal/Hans_Boehm/gc/gcdescr.html theoreticaly yes. but Qt has a nice "memory management":http://qt-project.org/wiki/Memory-management mechanism and i think it is not neccesary use some 3rd part lib for garbage collecting.