Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.6k Posts
  • Widget cross-platform (minimum) size constraint problem.

    4
    0 Votes
    4 Posts
    2k Views
    M
    Well, then resize it: @ widget.resize(new_width, new_height); @ The parameters are both integers.
  • Failed to start program. Path or permission wrong?

    5
    0 Votes
    5 Posts
    5k Views
    T
    I have the same issue. This message "Failed to start program. Path or permissions wrong?" shows up because qtcreator can't find Qt5Widgetsd.dll... but why? because i have it in /qtbase/libs/
  • [SOLVED] QLabel->isVisible always returns false

    10
    0 Votes
    10 Posts
    14k Views
    B
    Solved! Thanks Sam and willi4ms!
  • Images from MS Access database

    4
    0 Votes
    4 Posts
    2k Views
    R
    http://qt-project.org/forums/viewthread/12857
  • Doing multiple QNetworkRequest on the same QNetworkAccessManager

    9
    0 Votes
    9 Posts
    10k Views
    L
    Be aware that readyRead() only indicates that data is available, not necessarily that the reply has finished. If you want to pass information, for example a reference to the <code>VersionInfo</code> which was used to initiate the request you can use an "attribute":http://qt-project.org/doc/qt-5.0/qtnetwork/qnetworkrequest.html#setAttribute. QNetworkAccessManager provides a "finished":http://qt-project.org/doc/qt-5.0/qtnetwork/qnetworkaccessmanager.html#finished signal which passes the QNetworkReply. @ struct VersionInfo { ... }; Q_DECLARE_METATYPE(VersionInfo*) static const QNetworkRequest::Attribute VersionInfoAttribute = QNetworkRequest::User; ... connect(m_manager, &QNetworkAccessManager::finished, [](QNetworkReply reply) { VersionInfo versionInfo = reply->request().attribute(VersionInfoAttribute) .value<VersionInfo*>(); if (versionInfo != nullptr) { versionInfo->... } reply->deleteLater(); }); ... for (int counter = 0; counter < m_versionList.size(); counter++) { QNetworkRequest request; request.setAttribute(VersionInfoAttribute, QVariant::fromValue<VersionInfo*>(&m_versionList[counter])); request.setRawHeader("User-Agent", "Autoupdater"); request.setUrl(m_versionList[counter].changelog); m_manager->get(request); } @ If you don't want to connect to the finished(QNetworkReply*) signal (for instance because you are reusing the QNetworkAccessManager object and don't want to receive finished signals from other requests) you can use sender() (QNetworkReplyImpl is-a QNetworkReply).
  • Qt5 + CMake: How to add QtMain?

    2
    0 Votes
    2 Posts
    2k Views
    K
    I posted this question on StackOverflow as even here I don't have any answer :P http://stackoverflow.com/questions/14115024/how-to-link-qtmain-in-cmake-with-qt5
  • How to prevent QWidget::show() with QWidget::showEvent()

    6
    0 Votes
    6 Posts
    14k Views
    L
    If you take a look at the code you'll see that the widget is shown (<code>show_sys()</code>), regardless whether the event is accepted or not. It might make more sense if you take a look at the code for the "close event":http://code.woboq.org/qt5/qtbase/src/widgets/kernel/qwidget.cpp.html#7438 (<code>if (... && !e.isAccepted()) { ... return false; }</code>) for comparison. It can be quite confusing but as a rule of thumb every event is informational only, unless the documentation says otherwise. The fact that you don't receive subsequent show events for <code>show()</code> is an indicator that your widget is already shown (and so ignoring the event did not prevent that), although beeing invisible (for whatever reason). I'm not quite sure if there is even a non-hackish way of suppressing <code>show()</code>, overriding <code>setVisible()</code> included. You either don't <code>show()</code> the widget in the first place unless the data is available or you simply <code>show()</code> the widget and display an loading indicator until the data is available. Is this an option for you?
  • Access the widgets value from ui in other classes else mainWindow.

    1
    0 Votes
    1 Posts
    694 Views
    No one has replied
  • Save changes after closing a form.

    10
    0 Votes
    10 Posts
    4k Views
    Q
    You're welcome! Good job.
  • Porting Qt4 to Qt5: unresolved external symbols

    5
    0 Votes
    5 Posts
    4k Views
    C
    The Makefile file did not "become corrupted": it was exactly as you left it, full of commands and paths suitable for the previous Qt 4 installation. When Qt Creator ran nmake to build the project nmake did not automatically re-run qmake to generate the Makefile because the (untouched) Makefile was newer than the pro file that generated it. This is normal and correct make behaviour, but it resulted in a mismatch between your Qt5 in stall and expected Qt4 install.
  • File sorting and selection

    3
    0 Votes
    3 Posts
    2k Views
    F
    QTDavid, folderName is a private member of the class batchwindow I didn't find necessary to add it as an argument to populateTable() I have changed my model to QFileSystemModel and it works better now: @ void batchWindow::populateTable() { QDir directory(folderName); fileList = directory.entryList(); QFileSystemModel *model = new QFileSystemModel; model->removeColumn(3); elements->setModel(model); model->setRootPath(folderName); elements->setRootIndex(model->index(folderName)); elements->hideColumn(3); } @ I have also created a slot sortTable() that runs when a radio button is checked. @ void batchWindow::sortTable() { QDir directory(folderName); fileList = directory.entryList(); if (byFolder->isChecked()){ QFileSystemModel *model = new QFileSystemModel; elements->setModel(model); model->setRootPath(folderName); elements->setRootIndex(model->index(folderName)); elements->hideColumn(3); } if (byName->isChecked()){ } } @ It is a bit repetive but it works for the moment. I am now trying to figure out how to sort by name and by type.
  • Dual inheritance with library and QObject

    2
    0 Votes
    2 Posts
    1k Views
    U
    Put QObject first - always
  • [SOLVED] Dynamic Build Works; Static Build Fails

    2
    0 Votes
    2 Posts
    4k Views
    H
    [continued; I exceeded the character limit] I am completely at a loss as to why I get the 8 above errors with both parts uncommented to start with, and get a completely different error after some jiggery-pokery with commenting and un-commenting; I am confident that I followed exactly the same process as I did before when I successfully built the project statically. Online searches suggested that re-defining #defines used in header files could cause such errors, but, having skimmed qglobal.h, I am confident I haven't re-used any variable names. I would be extremely appreciative of any help to solve this problem; I'm stumped. Thank you in advance. main.cpp @#include <QtPlugin> Q_IMPORT_PLUGIN(qsqlite) Q_IMPORT_PLUGIN(qsvg) Q_IMPORT_PLUGIN(qtaccessiblewidgets) #include <QApplication> #include "homewindow.h" int main(int argc, char *argv[]) { QApplication app(argc, argv); HomeWindow *window = new HomeWindow(); window->show(); return app.exec&#40;&#41;; } @ .pro @OTHER_FILES += ... HEADERS += ... SOURCES += ... FORMS += ... QT += sql network svg script CONFIG += static static { CONFIG += static QTPLUGIN += qsqlite qsvg qtaccessiblewidgets DEFINES += static message("Static build.") } win32 { QMAKE_LFLAGS += -static-libgcc -static-libstdc++ }@ studywindow.h @#ifndef STUDYWINDOW_H #define STUDYWINDOW_H #include <QMainWindow> #include "dbfieldenums.h" #include <QSqlRelationalTableModel> #include <QSqlRecord> #include <QTime> #include <QNetworkAccessManager> #include <QNetworkReply> #include <QSvgWidget> namespace Ui { class StudyWindow; } class StudyWindow : public QMainWindow { Q_OBJECT public: explicit StudyWindow(QSqlRelationalTableModel *newItems, QSqlRelationalTableModel *reviewItems, QSqlRelationalTableModel *pNativeGenders, QSqlRelationalTableModel *pTargetGenders, quint16 userReactionInterval, quint16 userCharacterInterval, English pEnglish, QWidget *pCaller = 0, QWidget *parent = 0); ~StudyWindow(); protected: ... private: ... private slots: ... signals: ... }; #endif // STUDYWINDOW_H @ EDIT: I've since been able to fix my problem, which was actually two: The compiler errors were because my .pro file contained the line "DEFINES += static", which should have been "DEFINES += STATIC". The linker error was because my configure command (-qt-sql-sqlite) had built the qsqlite library into Qt - to use it as a plugin, I should have used -plugin-sql-sqlite. I think the seemingly random ever-changing nature of my errors was because I re-built the project in QtCreator without cleaning the build first. I hope this helps anybody else in a similar situation.
  • Problem with Qt 5 (Installation and Form Editor)

    1
    0 Votes
    1 Posts
    922 Views
    No one has replied
  • PDF Viewer Widget

    1
    0 Votes
    1 Posts
    1k Views
    No one has replied
  • OpenGL + Qt Not working for me

    3
    0 Votes
    3 Posts
    9k Views
    B
    [quote author="JKSH" date="1356842114"][quote author="brendan123746" date="1356818244"]I try running the Hello OpenGL Tutorial and it tells me :-1: warning: Qt was built with ANGLE, which provides only OpenGL ES 2.0 on top of DirectX 9.0c :-1: error: This example requires Qt to be configured with -opengl desktop[/quote]As the message says, the "Qt libraries 5.0.0 for Windows (VS 2010 406 MB)" was compiled using ANGLE for OpenGL support. ANGLE is a conversion layer that maps OpenGL commands to DirectX commands. Qt uses this by default on Windows, because Windows only supports OpenGL 1.1 by default, which is far too old for many Qt features (particularly Qt Quick). To make use of the OpenGL drivers provided by your graphics card, you'll need to compile Qt yourself (e.g. see http://qt-project.org/wiki/Building-Qt-5-from-Git ), passing the `-opengl desktop' flag to the configuration script. However, if you choose this path, you'll need to ensure that the users of your programs have hardware and drivers that support the version of OpenGLyou compiled against. Other alternatives are: Work on a Linux/Mac machine, which has better built-in OpenGL support than Windows Use Qt's OpenGL wrappers, which will work with both ANGLE and native OpenGL drivers[/quote] Thanks, really appreciate the input! Definitely not what i wanted to hear lol, but looks like i'm going to start compiling Qt lol
  • 0 Votes
    4 Posts
    3k Views
    V
    Thanks! Has to be like this: @bool CMainWindow::event(QEvent* e) { bool result = QWidget::event(e); if(e->type() == QEvent::WindowStateChange && isMinimized()) QTimer::singleShot(0, this, SLOT(hide())); return result; }@ Then it works as intended.
  • How to remove the codes when delete the widget of the Qt designer?

    5
    0 Votes
    5 Posts
    5k Views
    M
    [quote author="Jeroentje@home" date="1357043743"]Hi, Creating the "go to slot" is easy. Designer will add a private slot to your class definition. Delete the private definition and the class code and rerun qmake to alter the moc file. That's all. btw if you forget the deletion of the private definitions you get a compile error in the moc file! Good luck![/quote] Perfect... :) Thanks & Regards..
  • Wish You All a Very Happy New Year 2013...

    2
    0 Votes
    2 Posts
    2k Views
    A
    Good wishes for you and yours too =D Keep Coding coming =D
  • 0 Votes
    4 Posts
    2k Views
    M
    [quote author="sabby" date="1356953150"] if you use QFileDialog::getOpenFileName, you can browse files and add them.[/quote] That's Right...!!! QFileDialog::getOpenFileName () can be used to return the Existing Files selected by the user... Thanks & Regards...