Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.4k Posts
  • QSyntaxHighlighter - no bold text?

    Unsolved
    10
    0 Votes
    10 Posts
    888 Views
    mrjjM
    Hi I'm very interested as I thought it was impossible with QPlainTextEdit to alter any of the blocks to have other formatting but it sounds like you actually did that. Well QPlainTextEdit has a higher level interface than QTextDocument where you really have to fiddle around with internal building blocks. thx for the code :)
  • problem with userdefined widget with qtcreator ...

    Unsolved
    6
    0 Votes
    6 Posts
    441 Views
    mrjjM
    @django-Reinhard Hi If the file (the .h file) with the custom widget is not directly with the .PRO file then you must add the relative path to the place where you give it the .h when you promote like subfolder/mywidget.h
  • 0 Votes
    3 Posts
    221 Views
    mrjjM
    Hi Another poster asked the same so you can look at this sample https://www.dropbox.com/s/l8go4t71unosl05/CrossTalk.zip?dl=0 It sends info from one window to the other using signal and slots
  • Display a std::string in a QLineEdit in QT

    Unsolved
    8
    0 Votes
    8 Posts
    2k Views
    JKSHJ
    @amadeok said in Display a std::string in a QLineEdit in QT: on my pc the second function which reads normally the utf8 file takes about 130ms, while the first that converts to wstring while reading took about 750ms. That doesn't tell us anything useful, because QString is completely different from std::wstring. I extended your test on a 13MB .txt file (created by duplicating https://www.w3.org/2001/06/utf-8-test/UTF-8-demo.html 10x): QString qreadFile(const char* filename) { QFile src(filename); src.open(QFile::ReadOnly|QFile::Text); return QString::fromUtf8(src.readAll()); } QString qreadFile2(const QString& filename) { QFile src(filename); src.open(QFile::ReadOnly|QFile::Text); QTextStream stream(&src); stream.setCodec("UTF-8"); return stream.readAll(); } std::wstring wreadFile(const char* filename) { std::wifstream wif(filename); wif.imbue(std::locale(std::locale::empty(), new std::codecvt_utf8<wchar_t>)); std::wstringstream wss; wss << wif.rdbuf(); return wss.str(); } std::string readFile(const char* filename) { std::ifstream in(filename); std::stringstream ss; ss << in.rdbuf(); return ss.str(); } On my PC (MSVC 2019 32-bit): Reading std::wstring took 676ms Reading std::string took 135ms Reading QString took 53ms (both versions) So reading the file as a QString is faster than reading it as a std::string.
  • This topic is deleted!

    Unsolved
    3
    0 Votes
    3 Posts
    27 Views
  • X and Y mouse position

    Unsolved
    5
    0 Votes
    5 Posts
    282 Views
    A
    Ok thank you
  • QMediaPlayer on background thread?

    Solved
    10
    0 Votes
    10 Posts
    865 Views
    mrjjM
    @davecotter Assuming "after my app imports a thousand songs" talks about videos and hence we would have no benefit from processing sound files then yes to " no, you cant"
  • Externl images are not visible when running the application

    Solved
    6
    0 Votes
    6 Posts
    325 Views
    C
    Ah, I deleted the files from the folder and added the assets again. This time it worked. Weird that it didn't last time. Thanks for the help though!
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    8 Views
    No one has replied
  • qt rfid serialport

    Moved Unsolved
    12
    0 Votes
    12 Posts
    3k Views
    R
    @veysel-olgun sir, please share rfid coding
  • Show an Ellipse Move Around a Point

    Unsolved
    3
    0 Votes
    3 Posts
    189 Views
    mrjjM
    Hi I would try the geopainter sample first https://invent.kde.org/education/marble/-/tree/master/examples/cpp/geopainter
  • Compiling in g++

    Unsolved
    4
    1 Votes
    4 Posts
    4k Views
    C
    I am going to assume you are using the Qt versions installed by the online installer. On Linux this creates a folder Qt containing one folder for each Qt library version you chose to install (and some other stuff to support Qt Creator). For example: chrisw@newton:~/Qt$ ls -l total 31492 drwxrwxr-x 3 chrisw chrisw 4096 Jun 8 2020 5.15.0 drwxrwxr-x 3 chrisw chrisw 4096 Jun 20 13:24 6.1.1 -rw-r--r-- 1 chrisw chrisw 10174 Jul 4 12:48 components.xml ... Inside each Qt version folder is a complete set of Qt library components and tools identified by compiler(s): chrisw@newton:~/Qt$ ls -l 5.15.0/ total 8 drwxrwxr-x 13 chrisw chrisw 4096 Jun 8 2020 gcc_64 -rw-rw-r-- 1 chrisw chrisw 2271 May 14 2020 sha1s.txt chrisw@newton:~/Qt$ ls -l 5.15.0/gcc_64/ total 76 drwxr-xr-x 2 chrisw chrisw 4096 Jun 8 2020 bin drwxr-xr-x 4 chrisw chrisw 4096 Jun 8 2020 doc drwxr-xr-x 88 chrisw chrisw 4096 Jun 8 2020 include drwxr-xr-x 5 chrisw chrisw 28672 Jun 8 2020 lib drwxr-xr-x 2 chrisw chrisw 4096 Jun 8 2020 libexec drwxr-xr-x 76 chrisw chrisw 4096 Jun 8 2020 mkspecs drwxr-xr-x 2 chrisw chrisw 4096 Jun 8 2020 phrasebooks drwxr-xr-x 33 chrisw chrisw 4096 Jun 8 2020 plugins drwxr-xr-x 23 chrisw chrisw 4096 Jun 8 2020 qml drwxr-xr-x 2 chrisw chrisw 4096 Jun 8 2020 resources drwxr-xr-x 3 chrisw chrisw 12288 Jun 8 2020 translations If you run the qmake executable from the ~Qt/5.15.0/gcc_64/bin folder against your PRO file it will generate a Makefile that uses the tools and library under ~Qt/5.15.0/gcc_64 and the (in this example) the 64-bit GCC compiler. When you run make your project will be built with those tools and libraries. A Windows install will be similar but you may need to ensure the bundled MingW bin folder is in your PATH. So, from top to bottom: chrisw@newton:/tmp/demo$ cat main.cpp #include <QCoreApplication> #include <QDebug> int main(int argc, char **argv) { QCoreApplication app(argc, argv); qDebug() << "Excellent!"; return 0; } A basic PRO file starter can be created for you (one time only, after that you maintain this file yourself): chrisw@newton:/tmp/demo$ ~/Qt/5.15.0/gcc_64/bin/qmake -project chrisw@newton:/tmp/demo$ cat demo.pro ###################################################################### # Automatically generated by qmake (3.1) Sat Aug 28 09:32:14 2021 ###################################################################### TEMPLATE = app TARGET = demo INCLUDEPATH += . # You can make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # Please consult the documentation of the deprecated API in order to know # how to port your code away from it. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 # Input SOURCES += main.cpp Then you create the Makefile: chrisw@newton:/tmp/demo$ ~/Qt/5.15.0/gcc_64/bin/qmake chrisw@newton:/tmp/demo$ ls demo.pro main.cpp Makefile and build the project: chrisw@newton:/tmp/demo$ make g++ -c -pipe -O2 -Wall -Wextra -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I. -I. -I/home/chrisw/Qt/5.15.0/gcc_64/include -I/home/chrisw/Qt/5.15.0/gcc_64/include/QtGui -I/home/chrisw/Qt/5.15.0/gcc_64/include/QtCore -I. -isystem /usr/include/libdrm -I/home/chrisw/Qt/5.15.0/gcc_64/mkspecs/linux-g++ -o main.o main.cpp g++ -Wl,-O1 -Wl,-rpath,/home/chrisw/Qt/5.15.0/gcc_64/lib -o demo main.o /home/chrisw/Qt/5.15.0/gcc_64/lib/libQt5Gui.so /home/chrisw/Qt/5.15.0/gcc_64/lib/libQt5Core.so -lGL -lpthread chrisw@newton:/tmp/demo$ ./demo Excellent!
  • Incomprehensible crash maybe related to QT_CONFIG(accessibility)

    Unsolved
    2
    0 Votes
    2 Posts
    340 Views
    M
    In what file is that #ifdef QT_CONFIG(accessibility) line? Also, what is on the line before or after that? I don't think it can actually crash on a preprocessor directive line. What OS is this running on? I've noticed that MS Window's cdb debugger sometimes reports the wrong line that causes the crash (the actual line is either one before or one after).
  • Transparent Image not displaying correctly in QLabel

    Solved
    5
    0 Votes
    5 Posts
    924 Views
    DriftwoodD
    @raven-worx The checkered background, aside from other things, signifies image area that's transparent. By all rights, it shld vanish completely and allow the app bg color to fill in. I can only guess that some of the stock images were incorrectly created as being why I had trouble. But the last one, shown above, worked as expected. Thanks for your input. That's what got me thinking abt the legitimacy of the image's transparency.
  • setMapping or multiple QSignalMapper objects?

    Solved
    2
    0 Votes
    2 Posts
    136 Views
    SGaistS
    Hi, As shown in the class documentation you can do several mappings.
  • Problem Connection to Postgre SQL in Docker

    Solved
    4
    0 Votes
    4 Posts
    343 Views
    SGaistS
    Glad you found out and thanks for sharing ! Since you have it working now, please make the thread as solved so that other forum users may know a solution has been found :-)
  • QChart initialization error...

    Unsolved
    2
    0 Votes
    2 Posts
    338 Views
    JonBJ
    @potatolover9x Did you try moving the creation of the QChart (and all the rest of the QLineSeries stuff) after the QApplication a(myargc, myargv);? That should be essentially the first statement in a Qt program, before you instantiate any Qt objects.
  • Is there any way to get MAC address of remote IP (Same LAN) with QT code?

    Solved
    3
    0 Votes
    3 Posts
    653 Views
    S
    @JoeCFD thank you I got address by arp -a with bellow code QString getMacAddress(QString Ip) { QString outCmd, error; QProcess process; process.start("arp -a " + Ip); process.waitForFinished(); outCmd = process.readAllStandardOutput(); error = process.readAllStandardError(); // outCmd = "? (192.168.2.222) at 00:17:61:10:a9:47 [ether] on eth0\n"; if(error.isEmpty()) { QRegularExpression re(QStringLiteral("([a-fA-F0-9][a-fA-F0-9]:){5}[0-9a-fA-F][0-9a-fA-F]")); QRegularExpressionMatch match = re.match(outCmd); if(match.hasMatch()){ return match.captured(0); } } return ""; }
  • Different behaviour of icons in vista style vs fusion style?

    Unsolved fusion button icons
    4
    0 Votes
    4 Posts
    870 Views
    Christian EhrlicherC
    @mrjj Yes, sorry :D
  • How can I slow down the scroller speed if the scroll area is small

    Solved
    2
    0 Votes
    2 Posts
    297 Views
    JoeCFDJ
    https://doc.qt.io/qt-5/qscrollerproperties.html#FrameRates-enum Default one is 60. Try to set it to 20 and see if it helps.