Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.8k Posts
  • How to drag & drop rows within QTableWidget

    7
    0 Votes
    7 Posts
    23k Views
    G
    I wanted the same functionality for my app. So I searched through internet and didnt find anything. So I had to do it. So, you can do it with QTableWidget by using the cellEntered(int,int); then takeItem(row, col) and then setItem()... @connect(ui->tableWidget, SIGNAL(cellEntered(int,int)), this, SLOT(cellEnteredSlot(int,int)));@ @void MainWindow::cellEnteredSlot(int row, int column){ int colCount=ui->tableWidget->columnCount(); int rowsel; if(ui->tableWidget->currentIndex().row()<row) rowsel=row-1; //down else if(ui->tableWidget->currentIndex().row()>row) rowsel=row+1; //up else return; QList<QTableWidgetItem*> rowItems,rowItems1; for (int col = 0; col < colCount; ++col) { rowItems << ui->tableWidget->takeItem(row, col); rowItems1 << ui->tableWidget->takeItem(rowsel, col); } for (int cola = 0; cola < colCount; ++cola) { ui->tableWidget->setItem(rowsel, cola, rowItems.at(cola)); ui->tableWidget->setItem(row, cola, rowItems1.at(cola)); } }@ Warning: I think theres a bug. Although it works fine by clicking and holding the left mouse button and moving mouse up or down, it also works with Mouse WHEEL Scroll. I have not figure it out yet on how to check if mouse wheel was triggered so not to move selected row. The doc says: bq. This signal is only emitted when mouseTracking is turned on, or when a mouse button is pressed while moving into an item. BUT when you scroll the mouse wheel is not a mouse button press action. So I think its a BUG. Should I submit it?
  • [Solved] Operator<< Overloading for std::cout, does not work.

    4
    0 Votes
    4 Posts
    6k Views
    G
    It works in the header file if you have an operator definition inside a class declaration.
  • Mac right-to-left issue

    5
    0 Votes
    5 Posts
    2k Views
    G
    The application setting is just the default for the widgets.
  • [Solved] Catch application crash and/or display message

    9
    0 Votes
    9 Posts
    10k Views
    R
    Well if there are no more suggestions, I guess that leaves me no choice, lol, will have to check breakpad again. Thanks for the input everyone.
  • 0 Votes
    3 Posts
    2k Views
    G
    It depends on the method you use to get out of the editing cell. Using tab, for example, you can close the editor of the current cell and open the next cell. The close of the first cell triggers your slot, the message box takes way focus and thus triggers the close of the second cell's editor, hence your slot is called twice. Using qDebug() does not trigger this, as there is no popup stealing the focus. From a quick look at the docs, I doubt that it is ok to use two QErrorMessage dialogs simultaneously (what you probably do). I would add a member pointing to a pointer to a QErrorMessage dialog in the header, create that in the constructor and reuse that instead of creating a new msgBox every time. If that doesn't work, build your app in debug mode and run it through a debugger to get a useful stack trace.
  • QString::utf8() - is it re-entrant or not?

    7
    0 Votes
    7 Posts
    4k Views
    G
    Thanx for clarifying. I've added a "DocNote":/doc/qt-4.7/qstring.html#note-104 to [[Doc:QString]]'s online docs.
  • Need help on QTextEdit

    9
    0 Votes
    9 Posts
    8k Views
    G
    That code is given in the wiki page too. If you search a little bit you find a comment "reset the word highlight". You need to reset the extra highlight.
  • Phonon - Play several times

    5
    0 Votes
    5 Posts
    5k Views
    F
    Well, it is solved After large search i have the solution. I use createPlayer and VideoPlayer and it works pretty nice. And about the last problem that i reported, it is all about codecs... It worked in Windows xp but not in Windows 7, so I installed the k-lite codec and it works... but only if i try with the K-Lite codec for 32bits, if I install the 64bits version, or both, it does not work. http://www.codecguide.com/download_kl.htm @For use on 64-bit versions of Windows. For an optimal user experience it is highly recommended to also install one of the 32-bit variants from above, because most software that runs on 64-bit versions of Windows is still 32-bit. Windows Vista x64 and Windows 7 x64 use a 32-bit version of Windows Media Player by default. Windows Media Center and Windows Explorer are 64-bit applications. That is why you need both 32-bit and 64-bit codecs.@ Do not install both. Only the 32bit version ;) So be carefull with this... it took me a lot of time to figure it out.
  • QSystemTrayIcon[SOLVED]

    3
    0 Votes
    3 Posts
    2k Views
    D
    Thank you for your answer. Actually that one "yourApp.setQuitOnLastWindowClosed(false);" was enough.
  • Bad ptr when passing an argument

    11
    0 Votes
    11 Posts
    6k Views
    K
    the configure has an option -stl which is needed to be switched for using fromStdString and toStdString routines. I have just checked and it is a default value for the configuration. I had remembered that I had to set it explicitely somewhere (probably when compiling for win ce). However, if stl support is not on, you have received an error message during compilation. So, since it is default, it is a long shot anyhow.
  • Which class is more efficient to read the data from text file ?

    4
    0 Votes
    4 Posts
    2k Views
    F
    Please read the "documentation":http://doc.qt.nokia.com/4.7/qtextstream.html#details: bq. There are three general ways to use QTextStream when reading text files: Chunk by chunk, by calling readLine() or readAll(). Word by word. QTextStream supports streaming into QStrings, QByteArrays and char* buffers. Words are delimited by space, and leading white space is automatically skipped. Character by character, by streaming into QChar or char types. This method is often used for convenient input handling when parsing files, independent of character encoding and end-of-line semantics. To skip white space, call skipWhiteSpace().
  • Parent/Child Forms

    6
    0 Votes
    6 Posts
    4k Views
    M
    @Andre and fluca1978, I am loving it already... Thank you both. I will get the jargon right soon! Takes a while to "signal" from 1 braincell widget to the other :)
  • QListWidget: what signal for "item edition start" event?

    7
    0 Votes
    7 Posts
    4k Views
    D
    Right :) Read between the lines... >:)
  • Need help on building 'Help' from scratch.

    5
    0 Votes
    5 Posts
    2k Views
    Q
    [quote author="Lukas Geyer" date="1322721688"]Have you taken a look at the "Qt Help Framework Overview":http://doc.qt.nokia.com/stable/qthelp-framework.html?[/quote] That would be the best solution [quote author="justdad" date="1322715566"] The tutorials on the website assume prior knowledge which I don't have. Where do I start? [/quote] Which knowledge are you talking about?
  • How do I block a shortcut?

    2
    0 Votes
    2 Posts
    2k Views
    V
    Try this: http://doc.qt.nokia.com/4.7/qkeyevent.html#details Or this: http://doc.qt.nokia.com/4.7/qobject.html#eventFilter
  • Which code I must return?

    8
    0 Votes
    8 Posts
    3k Views
    G
    to koahnig: bq. When you change the return to a different value, does it output this new value? Yes, when I return a diffrent values, it show me respective values. to Tobias Hunger: bq. There was no error (otherwise it would say so in the message). Oh, okay... Simply, I been puzzled the image of the red circle with the white cross. Problem resolved, thanks!
  • 0 Votes
    1 Posts
    2k Views
    No one has replied
  • 0 Votes
    11 Posts
    5k Views
    L
    [quote author="Andre" date="1322655755"] Also, I would advice against an approach as sketched by Lukas above. Don't try to create your own format for defining UI geometries, but use what's there already instead. [/quote] The example was sketched under the precondition that .ui files are not applicable. If they can, .ui files are the way to go.
  • Multiple Widgets in QDialog -> Multiple "active" selections

    9
    0 Votes
    9 Posts
    4k Views
    S
    [quote author="Andre" date="1322646685"]No, that is not the right approach. Painting is done from the paintevent, and I have already laid out the options you have to manipulate that. Your way is not going to work. [/quote] Actually it worked with some tweaks here and there. But there were some side-effects I didn't think of. I tried creating custom delegates, which works as expected!
  • To any Qgraphics framework guru... need a solution...

    2
    0 Votes
    2 Posts
    2k Views
    V
    Well, not getting into much details here, is it possible that you make an extra, transparent layer on your image that would be another graphics scene over your graphics scene and let the drawing occur there? Then you could just move the element from the transparent scene to your actual scene.