Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.5k Topics 457.2k Posts
  • How to put QWidget objects on top of a QWindow?

    Unsolved
    3
    0 Votes
    3 Posts
    316 Views
    ?
    @JoeCFD I can only use QWindow, so the soluton inside the link doesn't apply. Thanks.
  • Default background colour for QToolbar?

    Unsolved
    3
    0 Votes
    3 Posts
    262 Views
    PerdrixP
    @SimonSchroeder Thank you
  • QNetworkAccessManager causes startup errors

    Solved
    6
    0 Votes
    6 Posts
    768 Views
    mzimmersM
    @JoeCFD @JonB ugh...this again. I think I was victimized by my own pedantry. When coding a function (including main), I really, really like to have all my variables declared before any code appears. Unfortunately, this doesn't seem to be possible in one case: // need to enable the keyboard via environment variable. // must be done before creation of QGuiApplication. qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard")); QGuiApplication app(argc, argv); QQmlApplicationEngine engine; My old solution was to have this code after all the other variable declarations; moving it to the top of main() did indeed fix the problem. Thanks guys.
  • How to make tableWidget.setItem accept a python list?

    Solved
    4
    0 Votes
    4 Posts
    481 Views
    SGaistS
    Hi, There's currently no real benefit with what you ask. QTableWidgetItem does not handle lists the way you want it. You would also need a custom delegate to render that list which, while not complicated, would mean a lot of list to string operation. This mean burning CPUs for nothing. Doing a join when creating the item and a split when you want to retrieve the data is both simple and cost effective.
  • QT 5.8 - how to get DIR list from FTP Server

    Unsolved
    6
    0 Votes
    6 Posts
    4k Views
    JonBJ
    @Peladosok As @VRonin said You can either recompile the old QFtp Module or use an external library like libcurl These days you're probably best using libcurl. There might be some sample FTP client code in Qt example https://doc.qt.io/qt-6/qtscxml-ftpclient-example.html
  • How to get the string list divided by QPainter with Qt::TextWordWrap?

    Solved
    2
    0 Votes
    2 Posts
    182 Views
    Christian EhrlicherC
    You're looking for QTextLayout - see https://code.qt.io/cgit/qt/qtbase.git/tree/src/gui/painting/qpainter.cpp#n7200
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    19 Views
    No one has replied
  • QGraphicsItem - automatically rearrange positions (space out)?

    Unsolved
    2
    0 Votes
    2 Posts
    159 Views
    JonBJ
    @nicholas_yue Not so far as I know. There is no "Tile" or "Cascade". Just write it yourself.
  • How to adapt the font size to the resolution of my image?

    Unsolved
    3
    0 Votes
    3 Posts
    359 Views
    JoeCFDJ
    @lincoln said in How to adapt the font size to the resolution of my image?: QImage Now you hard-coded the font size. You can set coefficient which is determined by the width or height of your image. painter.setFont(QFont("Arial", coef * newImage.width() Or coef * newImage.height())); Note that your image may need to be scaled as well for your widget. I use pixel size in font. Yours is not pixel size and you may need a global and consistent usage of font unit. QFont("Arial", 20 ) 20 is point size, not pixel size.
  • How do I get Qt-Versions on my Raspberry Pi to create the kit?

    Unsolved
    2
    0 Votes
    2 Posts
    198 Views
    JoeCFDJ
    @Samuel123 I guess you need to install a Qt version for qt creator.
  • Setting a backgroung image for a QPushButton does not work

    Unsolved
    7
    0 Votes
    7 Posts
    1k Views
    Q
    @JoeCFD I tried to set the button size first and I am still getting the same behavior. I was wondering if you could share your code, I am sure I'm missing something obvious. Many thanks!
  • How to get a pointer to a specific widget when you know only its name?

    Solved
    8
    0 Votes
    8 Posts
    799 Views
    JonBJ
    @Ylvy Yes, if you want to find a top-level window, assuming your QMainWindow is such, and you are somewhere that does not have access to your QMainWindow* variable, walk (don't descend) QWidgetList QApplication::topLevelWidgets() for a QMainWindow*. Then use that for mainWindow->findChild<YourWidgetClass*>("SpecificWidgetObjectName"); I use this for debugging purposes. It may not be a sign of great design if your code really needs to find the main window for this purpose.
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    2 Views
    No one has replied
  • QRegExp does not support unicode 16 bit character?

    Solved
    9
    0 Votes
    9 Posts
    836 Views
    C
    @king558 I use this little gem r12a >> apps >> Unicode code converter. Paste in the text to convert (e.g. 📉) and out pops it encoded in various ways ready to paste in elsewhere. Or, provide the 16-bit words of a UTF-16 encoding and out pop the characters. The Wikipedia page for UTF-16 describes how the surrogates encode the higher code points.
  • command line and GUI at same time

    Solved
    12
    0 Votes
    12 Posts
    3k Views
    Paul ColbyP
    Here's a possibly relevant example from the QApplication docs: Some GUI applications provide a special batch mode ie. provide command line arguments for executing tasks without manual intervention. In such non-GUI mode, it is often sufficient to instantiate a plain QCoreApplication to avoid unnecessarily initializing resources needed for a graphical user interface. The following example shows how to dynamically create an appropriate type of application instance: QCoreApplication* createApplication(int &argc, char *argv[]) { for (int i = 1; i < argc; ++i) { if (!qstrcmp(argv[i], "-no-gui")) return new QCoreApplication(argc, argv); } return new QApplication(argc, argv); } int main(int argc, char* argv[]) { QScopedPointer<QCoreApplication> app(createApplication(argc, argv)); if (qobject_cast<QApplication *>(app.data())) { // start GUI version... } else { // start non-GUI version... } return app->exec(); } Cheers.
  • How to download Qt Creator from mirror and build a simple Linux app?

    Unsolved
    3
    0 Votes
    3 Posts
    1k Views
    jsulmJ
    @Jason-Rich-Darmawan said in How to download Qt Creator from mirror and build a simple Linux app?: ./configure make make install This is only needed if you want to build Qt or QtCreator from source.
  • How QString conversions works these days? Is ICU still used?

    Unsolved
    2
    0 Votes
    2 Posts
    187 Views
    jsulmJ
    @shenlebantongying said in How QString conversions works these days? Is ICU still used?: how QString::toStdU32String and QString::fromUtf8 You could take a look at the implementation of these methods
  • Qlocale::toDateTime() issue

    Solved
    15
    0 Votes
    15 Posts
    2k Views
    AndyBriceA
    @SGaist I finally managed to reproduce the issue by changing my Windows time zone to Santiago! So mystery solved. [image: 334c904f-ddc8-49fc-a9fc-9ed187ab0e5e.png] Set to Santiago: initial system locale= "en_GB" QTimeZone::systemTimeZone()= QTimeZone("America/Santiago") dt.toString( "03-09-2023 0:00:00" , "dd-MM-yyyy H:mm:ss" ), dt.isValid()= false dt.toString()= "" dt.toString( "01-01-2023 0:00:00" , "dd-MM-yyyy H:mm:ss" ), dt.isValid()= true dt.toString()= "Sun Jan 1 00:00:00 2023" dt.toString( "04-09-2022 0:00:00" , "dd-MM-yyyy H:mm:ss" ), dt.isValid()= false dt.toString()= "" dt.toString( "01-01-2022 0:00:00" , "dd-MM-yyyy H:mm:ss" ), dt.isValid()= true dt.toString()= "Sat Jan 1 00:00:00 2022" dt.toString( "05-09-2021 0:00:00" , "dd-MM-yyyy H:mm:ss" ), dt.isValid()= false dt.toString()= "" dt.toString( "01-01-2021 0:00:00" , "dd-MM-yyyy H:mm:ss" ), dt.isValid()= true dt.toString()= "Fri Jan 1 00:00:00 2021" QLocale::setDefault( QLocale( QLocale::English, QLocale::UnitedKingdom ) ) system locale= "en_GB" dt.toString( "03-09-2023 0:00:00" , "dd-MM-yyyy H:mm:ss" ), dt.isValid()= false dt.toString()= "" dt.toString( "01-01-2023 0:00:00" , "dd-MM-yyyy H:mm:ss" ), dt.isValid()= true dt.toString()= "Sun Jan 1 00:00:00 2023" dt.toString( "04-09-2022 0:00:00" , "dd-MM-yyyy H:mm:ss" ), dt.isValid()= false dt.toString()= "" dt.toString( "01-01-2022 0:00:00" , "dd-MM-yyyy H:mm:ss" ), dt.isValid()= true dt.toString()= "Sat Jan 1 00:00:00 2022" dt.toString( "05-09-2021 0:00:00" , "dd-MM-yyyy H:mm:ss" ), dt.isValid()= false dt.toString()= "" dt.toString( "01-01-2021 0:00:00" , "dd-MM-yyyy H:mm:ss" ), dt.isValid()= true dt.toString()= "Fri Jan 1 00:00:00 2021" QLocale::setDefault( QLocale( QLocale::Spanish, QLocale::Chile ) ) system locale= "es_CL" dt.toString( "03-09-2023 0:00:00" , "dd-MM-yyyy H:mm:ss" ), dt.isValid()= false dt.toString()= "" dt.toString( "01-01-2023 0:00:00" , "dd-MM-yyyy H:mm:ss" ), dt.isValid()= true dt.toString()= "Sun Jan 1 00:00:00 2023" dt.toString( "04-09-2022 0:00:00" , "dd-MM-yyyy H:mm:ss" ), dt.isValid()= false dt.toString()= "" dt.toString( "01-01-2022 0:00:00" , "dd-MM-yyyy H:mm:ss" ), dt.isValid()= true dt.toString()= "Sat Jan 1 00:00:00 2022" dt.toString( "05-09-2021 0:00:00" , "dd-MM-yyyy H:mm:ss" ), dt.isValid()= false dt.toString()= "" dt.toString( "01-01-2021 0:00:00" , "dd-MM-yyyy H:mm:ss" ), dt.isValid()= true dt.toString()= "Fri Jan 1 00:00:00 2021" Set to London: initial system locale= "en_GB" QTimeZone::systemTimeZone()= QTimeZone("Europe/London") dt.toString( "03-09-2023 0:00:00" , "dd-MM-yyyy H:mm:ss" ), dt.isValid()= true dt.toString()= "Sun Sep 3 00:00:00 2023" dt.toString( "01-01-2023 0:00:00" , "dd-MM-yyyy H:mm:ss" ), dt.isValid()= true dt.toString()= "Sun Jan 1 00:00:00 2023" dt.toString( "04-09-2022 0:00:00" , "dd-MM-yyyy H:mm:ss" ), dt.isValid()= true dt.toString()= "Sun Sep 4 00:00:00 2022" dt.toString( "01-01-2022 0:00:00" , "dd-MM-yyyy H:mm:ss" ), dt.isValid()= true dt.toString()= "Sat Jan 1 00:00:00 2022" dt.toString( "05-09-2021 0:00:00" , "dd-MM-yyyy H:mm:ss" ), dt.isValid()= true dt.toString()= "Sun Sep 5 00:00:00 2021" dt.toString( "01-01-2021 0:00:00" , "dd-MM-yyyy H:mm:ss" ), dt.isValid()= true dt.toString()= "Fri Jan 1 00:00:00 2021" QLocale::setDefault( QLocale( QLocale::English, QLocale::UnitedKingdom ) ) system locale= "en_GB" dt.toString( "03-09-2023 0:00:00" , "dd-MM-yyyy H:mm:ss" ), dt.isValid()= true dt.toString()= "Sun Sep 3 00:00:00 2023" dt.toString( "01-01-2023 0:00:00" , "dd-MM-yyyy H:mm:ss" ), dt.isValid()= true dt.toString()= "Sun Jan 1 00:00:00 2023" dt.toString( "04-09-2022 0:00:00" , "dd-MM-yyyy H:mm:ss" ), dt.isValid()= true dt.toString()= "Sun Sep 4 00:00:00 2022" dt.toString( "01-01-2022 0:00:00" , "dd-MM-yyyy H:mm:ss" ), dt.isValid()= true dt.toString()= "Sat Jan 1 00:00:00 2022" dt.toString( "05-09-2021 0:00:00" , "dd-MM-yyyy H:mm:ss" ), dt.isValid()= true dt.toString()= "Sun Sep 5 00:00:00 2021" dt.toString( "01-01-2021 0:00:00" , "dd-MM-yyyy H:mm:ss" ), dt.isValid()= true dt.toString()= "Fri Jan 1 00:00:00 2021" QLocale::setDefault( QLocale( QLocale::Spanish, QLocale::Chile ) ) system locale= "es_CL" dt.toString( "03-09-2023 0:00:00" , "dd-MM-yyyy H:mm:ss" ), dt.isValid()= true dt.toString()= "Sun Sep 3 00:00:00 2023" dt.toString( "01-01-2023 0:00:00" , "dd-MM-yyyy H:mm:ss" ), dt.isValid()= true dt.toString()= "Sun Jan 1 00:00:00 2023" dt.toString( "04-09-2022 0:00:00" , "dd-MM-yyyy H:mm:ss" ), dt.isValid()= true dt.toString()= "Sun Sep 4 00:00:00 2022" dt.toString( "01-01-2022 0:00:00" , "dd-MM-yyyy H:mm:ss" ), dt.isValid()= true dt.toString()= "Sat Jan 1 00:00:00 2022" dt.toString( "05-09-2021 0:00:00" , "dd-MM-yyyy H:mm:ss" ), dt.isValid()= true dt.toString()= "Sun Sep 5 00:00:00 2021" dt.toString( "01-01-2021 0:00:00" , "dd-MM-yyyy H:mm:ss" ), dt.isValid()= true dt.toString()= "Fri Jan 1 00:00:00 2021"
  • QCamera example / error handling

    Unsolved
    1
    0 Votes
    1 Posts
    196 Views
    No one has replied
  • I want to restrict access from specific IP addresses.

    Solved
    7
    0 Votes
    7 Posts
    627 Views
    R
    Axel Spohr. Thanks for the advice. I have learned a lot from this forum. Thank you all for taking the time to share with me.