Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.4k Topics 456.4k Posts
  • Using my own window / hwnd

    2
    0 Votes
    2 Posts
    2k Views
    A
    Subclass QWidget and take a look on the protected function "QWidget::create":http://qt-project.org/doc/qt-4.8/qwidget.html#create Wid is an HWND
  • 0 Votes
    3 Posts
    9k Views
    R
    Nice..
  • [Solved]How to list all files on linux correctly

    5
    0 Votes
    5 Posts
    2k Views
    A
    Thanks, it worked!
  • [Solved] QScriptEngine instantiation closes application.

    2
    0 Votes
    2 Posts
    1k Views
    Q
    I found the problem. I was adding QtScript4.lib and this was causing the crash. The correct library, seems to be QtScriptd4.lib, after I made this change my application now runs.
  • Creating dynamic properties with ui elements

    2
    0 Votes
    2 Posts
    3k Views
    A
    According to the "Style sheet syntax page":http://qt-project.org/doc/qt-4.8/stylesheet-syntax.html#selector-types: bq. Warning: If the value of the Qt property changes after the style sheet has been set, it might be necessary to force a style sheet recomputation. One way to achieve this is to unset the style sheet and set it again. Repolishing the widget after changing the property also seems to work: @ui->label_auto->style()->polish(ui->label_auto); // or qApp->postEvent(ui->label_auto, new QEvent(QEvent::Polish));@ bq. But how do I set the properties, using this macro, of a ui-> element? I'm not sure what you mean by that. But if you declare the property in the window, rather than in a class derived from QLabel, you can set the stylesheet to the window, and add another level to the label selector. You would still have to force the style sheet recalculation, but you can put the code that'll do it in the property setter: @ // this represents the window this->setStyleSheet("*[opmode='A'] #label_auto { background-color: lime } *[opmode='B'] #label_auto { background-color: red }" ); this->setProperty("opmode", A); // with class YourClass : public QWidget { ... Q_PROPERTY(QString opmode READ opmode WRITE setOpmode) ... QString _opmode; void setOpmode(const QString &value) { if(_opmode != value) { _opmode = value; style()->polish(ui->label_auto); } } QString opmode() const { return _opmode; } }; @ Another way to achieve the same result, if you have only 2 or 3 states would be to use a disabled QCheckBox, and use its checked/unchecked/indeterminate pseudo-states in the stylesheet.
  • [solved]Qt: Untested Windows version 8.3 detected! Error

    9
    0 Votes
    9 Posts
    29k Views
    M
    I ran into a similar error when I tried to build a Visual Studio 2010 solution after upgrading to Windows 8. Qt: Untested Windows version 6.2 detected! 1> Qt User Interface Compiler version 4.7.4 1> Usage: c:\Qt474-msvc2010\bin\uic.exe [options] <uifile> 1> 1> -h, -help display this help and exit 1> -v, -version display version 1> -d, -dependencies display the dependencies 1> -o <file> place the output into <file> 1> -tr <func> use func() for i18n 1> -p, -no-protection disable header protection 1> -n, -no-implicit-includes disable generation of #include-directives 1> for forms generated by uic3 1> -g <name> change generator 1> 1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(151,5): error MSB6006: "cmd.exe" exited with code 1. The root directory for my solution was C:\Development\PI_Local S23 If I changed it to C:\Development\PI_Local_S23 The projects would still get the warning but they would build. I'm assuming that the space in the path name made a difference?
  • [Solved] QDate::fromString() dateformat restrictions.

    8
    0 Votes
    8 Posts
    21k Views
    M
    If it's solved, be sure and edit your initial post and change the title to add [Solved]. Thanks!
  • [Solved] Use PostgreSQL C Api

    4
    0 Votes
    4 Posts
    2k Views
    D
    Hi, Good to know.
  • 0 Votes
    8 Posts
    5k Views
    K
    Hi I solved it. The Problem was a wron initialized array Pointer: I devinded it as follows: @ //.h PixelCanvasTile *myTiles; @ then in the function loop: @ for(i < n){ myTiles = new PixelCanvasTiles(); myTiles ++; @ now it is: @ //.h PixelCanvasTile **myTiles; // construtor: myTiles = new PixelCanvasTile*[size]; @ in function: @for(i < n){ myTiles[i] = new PixelCanvasTile(); }@
  • QSharedData and mutable members: Calling detach() from const method?

    1
    0 Votes
    1 Posts
    935 Views
    No one has replied
  • Rotating Image.

    2
    0 Votes
    2 Posts
    2k Views
    A
    You can use "QImage::transformed":http://qt-project.org/doc/qt-4.8/qimage.html#transformed-2 function with "QTransform::rotate":http://qt-project.org/doc/qt-4.8/qtransform.html#rotate as the first argument to rotate your QImage
  • 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.