Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.8k Posts
  • new a model to a simple table ;

    Unsolved
    7
    0 Votes
    7 Posts
    438 Views
    Christian EhrlicherC
    @Pl45m4 said in new a model to a simple table ;: integrated in the parent/child hierarchy and therefore deleted with parent (i.e. Dialog class)?! Yes, but that's imo much too late here.
  • 0 Votes
    8 Posts
    860 Views
    JoeCFDJ
    @Chris-Kawa Tested it. Works nicely. Many thanks.
  • Changes not applied after compiling and running (QT Creator)

    Unsolved qtcreator
    5
    0 Votes
    5 Posts
    886 Views
    Axel SpoerlA
    @eucor, and that has fixed the problem generally, or do you have to delete & restart every time? Maybe the build tree is broken, or the virus scanner steps on the compiler's toes.
  • How to Properly Set a QCursor with a Mask?

    Solved qcursor qimage qpixmap
    4
    0 Votes
    4 Posts
    852 Views
    G
    I have made continuous attempts and discovered some patterns in color conversion. The official documentation of QCursor mentions Qt::color0 and Qt::color1, which indeed follow certain rules. However, I found that the results I obtained are the opposite of the bit values. As mentioned in my comments, I am currently inverting the bit values of the Windows original AND mask and XOR mask to match Qt::color0 and Qt::color1 as mentioned in the QCursor documentation. /** * type: MONOCHAROME has (AND bitmap) and (XOR bitmap). * 1 bit = 1 pixed * * Windows: * AND bitmap XOR bitmap Display * 0 0 Black * 0 1 White * 1 0 Screen * 1 1 Reverse screen * * QCursor: * The cursor bitmap (B) and mask (M) bits are combined like this: * B=1 and M=1 gives black. * B=0 and M=1 gives white. * B=0 and M=0 gives transparent. * B=1 and M=0 gives an XOR'd result under Windows, undefined results on all other platforms. * Use the global Qt color Qt::color0 to draw 0-pixels and Qt::color1 to draw 1-pixels in the bitmaps. * * Actual results: * 0 0 Black * 1 0 White * 1 1 transparent screen * 0 1 Reverse screen */ int size = pCursorData->width * pCursorData->height / 2 / 8; if(pCursorData->dataLen / 2 != size) { qWarning() << "[CMouseModule::SetServerCursor] set Cursor Data dataLen failed."; return; } QImage image(pCursorData->width, pCursorData->height / 2, QImage::Format_Mono); QImage maskImage(pCursorData->width, pCursorData->height / 2, QImage::Format_Mono); if(image.sizeInBytes() != size) { qWarning() << "[CMouseModule::SetServerCursor] bitmap size not eq Cursor Data image size."; return; } uchar* imageBits = image.bits(); uchar* maskImageBits = maskImage.bits(); int pitch = pCursorData->dataLen / pCursorData->height; bool andPixel; bool xorPixel; // // `height` is 2 bitmap; for(int y=0; y < pCursorData->height / 2; y++) { for(int x=0; x < pCursorData->width; x++) { quint8 bitMask = 0x80 >> (x % 8); quint8 uint8_x = x / 8; // width is bit size andPixel = pCursorData->pixelData[y * pitch + uint8_x] & bitMask; xorPixel = pCursorData->pixelData[(y + pCursorData->height / 2) * pitch + uint8_x] & bitMask; if(!andPixel && !xorPixel) { imageBits[y * pitch + uint8_x] &= ~bitMask; // 0 maskImageBits[y * pitch + uint8_x] &= ~bitMask; // 0 } else if(!andPixel && xorPixel) { imageBits[y * pitch + uint8_x] |= bitMask; // 1 maskImageBits[y * pitch + uint8_x] &= ~bitMask; // 0 } else if(andPixel && !xorPixel) { imageBits[y * pitch + uint8_x] |= bitMask; // 1 maskImageBits[y * pitch + uint8_x] |= bitMask; // 1 } else if(andPixel && xorPixel) { imageBits[y * pitch + uint8_x] &= ~bitMask; // 0 maskImageBits[y * pitch + uint8_x] |= bitMask; // 1 } } } QBitmap bitmap; QBitmap maskBitmap; bitmap = QBitmap::fromImage(image); maskBitmap = QBitmap::fromImage(maskImage); QCursor cursor(bitmap, maskBitmap, pCursorData->xHotspot, pCursorData->yHotspot); renderWidget->setCursor(cursor);
  • Application Plugins in WebAssembly wasm

    Unsolved
    1
    0 Votes
    1 Posts
    179 Views
    No one has replied
  • Porting a simple shader from Qt5 to Qt6

    Solved
    3
    0 Votes
    3 Posts
    720 Views
    R
    @Chris-Kawa said in Porting a simple shader from Qt5 to Qt6: @RobertB texture2D function is deprecated in GLSL v440 and only available in compatibility profile. Replace it with generic texture function. That worked, thanks. Trying to port the vertex shader now, but can't get it to work. I don't know what are inputs, or outputs, and how both frag/vert variables interact with eachother (if at all). Ill give up on this :-)
  • QuaZip does not unpack zip compressed folders

    Solved
    5
    0 Votes
    5 Posts
    581 Views
    posktomtenP
    Error checking read/write connect(ui->pbUnpack, &QPushButton::clicked, [this]() { QString ziped = "../svtplay-dl-4.28.1.zip"; QString unziped = ".."; QuaZip zip(ziped); // Open the zip file for reading if(zip.open(QuaZip::mdUnzip)) { // qDebug() << "Zip file opened successfully."; QDir dir; for(bool more = zip.goToFirstFile(); more; more = zip.goToNextFile()) { QString filePath = zip.getCurrentFileName(); QFileInfo fi(filePath); QString dirpath = fi.path(); dir.mkpath(unziped + "/" + dirpath); QuaZipFile zFile(zip.getZipName(), filePath); // Open the source file in the zip file for reading if(zFile.open(QIODevice::ReadOnly)) { // qDebug() << "Opened file in zip for reading: " << filePath; QByteArray ba = zFile.readAll(); zFile.close(); QFile dstFile(unziped + "/" + filePath); // Open the destination for writing QFileInfo fi(dstFile); // If it is a directory, an error message will appear if(fi.isDir()) { continue; } if(dstFile.open(QIODevice::WriteOnly)) { if(dstFile.isOpen()) { dstFile.write(ba.data(), ba.size()); dstFile.close(); // qDebug() << "Write successful."; } else { qDebug() << "Destination file is not open for writing."; } } else { qDebug() << "Could not open destination file (dstFile) for writing: " << dstFile.errorString(); } } else { qDebug() << "Could not open file in zip for reading: " << filePath; } } zip.close(); qDebug() << "Done."; } else { qDebug() << "Could not open zip file: " << ziped; } });
  • QAudioOutput real time delay problem

    Unsolved
    1
    0 Votes
    1 Posts
    295 Views
    No one has replied
  • QFileInfo::birthTime() returns nothing (on Ubuntu)

    Solved c++qt linux desktop linux
    5
    0 Votes
    5 Posts
    1k Views
    JonBJ
    OP's Ubuntu should support stat file for Birth. See e.g. How to Find Out When a File Was Created in Linux for a recent discussion of the issues.
  • Creating QQuick Items from C++

    Unsolved
    8
    0 Votes
    8 Posts
    613 Views
    Pl45m4P
    @Asperamanca I'm just curious, because I've never heard of it and usually you would design the QuickItems in their QMLanguage on QtQuick side and then connect your C++ code to it
  • System Sounds

    Unsolved
    4
    0 Votes
    4 Posts
    559 Views
    S
    I assume QApplication::beep() is just sending \a to the console. This would also the reason why this cannot be expanded to other system sounds.
  • Unknown user Input Type: xxx

    Unsolved qchart
    3
    0 Votes
    3 Posts
    909 Views
    I
    @jsulm No I didn't. However, the problem never appeared after I added "chartview->setViewportUpdateMode(QChartView::FullViewportUpdate)". I just assume it's solved...
  • 0 Votes
    20 Posts
    3k Views
    H
    @SGaist That's right. Thanks everyone
  • 0 Votes
    2 Posts
    477 Views
    SGaistS
    Hi and welcome to devnet, If you positioned everything by hand then you either have to redo that or position your widgets in your code for example in the resizeEvent method. Otherwise, the recommended way to work is to use layouts which automatically adapts to the size of your widget.
  • How to see signal slot Queue size?

    Unsolved
    9
    0 Votes
    9 Posts
    2k Views
    SGaistS
    Beside the good point made @jsulm, since you know that your whole processing chain is slow, why are you reading the file faster than what your processing chain can do ? Rather than pushing images as fast as the reader can, you should pull them as fast as your processing chain allows. The way you build your chain just complicate things for no real benefit.
  • How to draw a transparent area selection box

    Solved qtwidgets
    9
    0 Votes
    9 Posts
    1k Views
    JonBJ
    @jeremy_k said in How to draw a transparent area selection box: If there's no initial underlying window belonging to the application, the window manager is going to have to cooperate and not deliver the mouse button press to something else. That's the sort of thing I was thinking of. I didn't know plain applications had access to the visual desktop, only to the windows the manager allowed it to create. But I don't really know.
  • QHeaderView induvidual background colors

    Solved
    19
    0 Votes
    19 Posts
    1k Views
    Andy314A
    @JonB said in QHeaderView induvidual background colors: @Andy314 What I do not know is why/how a derived QHeaderView does not get this set as a base QHeaderView does. Perhaps a Qt/C++ expert would care to enlighten us? That is exact the problem I struggled. From the logic it can only be that the QTableView itself configures its QHeaderView correct. Indeed I found the code for it: void QTableViewPrivate::init() { Q_Q(QTableView); q->setEditTriggers(editTriggers|QAbstractItemView::AnyKeyPressed); QHeaderView *vertical = new QHeaderView(Qt::Vertical, q); vertical->setSectionsClickable(true); vertical->setHighlightSections(true); q->setVerticalHeader(vertical); QHeaderView *horizontal = new QHeaderView(Qt::Horizontal, q); horizontal->setSectionsClickable(true); // Here is the code **************************** horizontal->setHighlightSections(true); q->setHorizontalHeader(horizontal); tabKeyNavigation = true; #if QT_CONFIG(abstractbutton) cornerWidget = new QTableCornerButton(q); cornerWidget->setFocusPolicy(Qt::NoFocus); QObject::connect(cornerWidget, SIGNAL(clicked()), q, SLOT(selectAll())); #endif }
  • QProcess::startDetached() doesn't work on self-written programs

    Solved qprocess startdetached
    17
    0 Votes
    17 Posts
    3k Views
    Q
    @Christian-Ehrlicher, @JonB I deployed the two programs again and had the same problem as before. Then I went through all the deployed .dll's and there were some missing. I copied them inside the folder manually and now it works. So the problem was windeployqt or some missing windeployqt-commands while deploying. Thank you again, I'll close this topic now.
  • Exceptions thrown in slots are crashing the application only on macOS

    Solved
    3
    0 Votes
    3 Posts
    552 Views
    rkhaotixR
    @Chris-Kawa Hi Chris! Thanks for your response. Just to be clear, the message box display is the end of the route of an exception. There I have a stack trace which helps me a lot to debug and fix problems. Also, the wrapper I'm doing is just a workaround while I track down all the slots that are not capturing the exception inside them and letting the exceptions go out. That's not going to work. It's not connect that throws. The code that throws is invoked in the signal call when it's a direct connection or on the thread the slot is in when it's a queued connection. I understand that now. Thanks. Just don't let exceptions escape slots. There are tons of slots that already do that. But, unfortunately, the ones that are letting exceptions escape are in great amounts too. So, I have a lot of refactoring to do. :) If Messagebox is based on Qt UI (e.g. widgets) this shouldn't be called from non-UI thread, so you can't call it as a generic exception handler, since you don't know what thread might throw. Yes, it is. The problem I mentioned is only happening on UI threads. Anyway, thanks again for your time explaining that. It helped a lot to understand what's wrong, and how I can fix that and avoid falling on that pitfall again. Have a nice day!
  • QCustomPlot adding subTicks

    Unsolved
    1
    0 Votes
    1 Posts
    315 Views
    No one has replied